List of usage examples for org.apache.commons.collections CollectionUtils size
public static int size(Object object)
From source file:eu.europa.esig.dss.tsl.service.TSLRepository.java
public List<TSLValidationSummary> getSummary() { Map<String, TSLValidationModel> map = getAllMapTSLValidationModels(); List<TSLValidationSummary> summaries = new ArrayList<TSLValidationSummary>(); for (Entry<String, TSLValidationModel> entry : map.entrySet()) { String country = entry.getKey(); TSLValidationModel model = entry.getValue(); TSLValidationSummary summary = new TSLValidationSummary(); summary.setCountry(country);//www . j a va 2 s .com summary.setLoadedDate(model.getLoadedDate()); summary.setTslUrl(model.getUrl()); TSLParserResult parseResult = model.getParseResult(); if (parseResult != null) { summary.setSequenceNumber(parseResult.getSequenceNumber()); summary.setIssueDate(parseResult.getIssueDate()); summary.setNextUpdateDate(parseResult.getNextUpdateDate()); int nbServiceProviders = 0; int nbServices = 0; int nbCertificatesAndX500Principals = 0; List<TSLServiceProvider> serviceProviders = parseResult.getServiceProviders(); if (serviceProviders != null) { nbServiceProviders = serviceProviders.size(); for (TSLServiceProvider tslServiceProvider : serviceProviders) { List<TSLService> services = tslServiceProvider.getServices(); if (services != null) { nbServices += services.size(); for (TSLService tslService : services) { List<CertificateToken> certificates = tslService.getCertificates(); List<X500Principal> x500Principals = tslService.getX500Principals(); nbCertificatesAndX500Principals += CollectionUtils.size(certificates); nbCertificatesAndX500Principals += CollectionUtils.size(x500Principals); } } } } summary.setNbServiceProviders(nbServiceProviders); summary.setNbServices(nbServices); summary.setNbCertificatesAndX500Principals(nbCertificatesAndX500Principals); } TSLValidationResult validationResult = model.getValidationResult(); if (validationResult != null) { summary.setIndication(validationResult.getIndication()); } summaries.add(summary); } return summaries; }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
private void addToProfileBrowser(String newProfileName) { if (!lvProfiles.getItems().contains(newProfileName)) { int pos = 0; for (; pos < CollectionUtils.size(lvProfiles.getItems()); pos++) { String pn = lvProfiles.getItems().get(pos); if (pn.compareToIgnoreCase(newProfileName) > 0) { break; }/*from w w w . j av a2 s . c o m*/ } lvProfiles.getItems().add(pos, newProfileName); lvProfiles.getSelectionModel().select(pos); } }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
void recordRecentProfile(String newProfileName) { if (activeConfiguration.getRecentProfiles().contains(newProfileName)) { return; // can assume activeConfiguration is accurate }/*from www.j av a 2 s.c om*/ // // #18 record recent history on save // List<MenuItem> rpItems = mRecentProfiles.getItems(); MenuItem rpItem = new MenuItem(newProfileName); rpItem.setOnAction(recentProfileLoadHandler); if (CollectionUtils.isNotEmpty(rpItems)) { if (CollectionUtils.size(rpItems) == 1) { if (StringUtils.equalsIgnoreCase(rpItems.get(0).getText(), MI_NO_PROFILES.getText())) { rpItems.set(0, rpItem); } else { rpItems.add(0, rpItem); } } else { rpItems.add(0, rpItem); if (CollectionUtils.size(rpItems) > numRecentProfiles) { for (int i = (CollectionUtils.size(rpItems) - 1); i >= numRecentProfiles; i--) { rpItems.remove(i); } } } } else { // should never have no items (at least one < None >) rpItems.add(rpItem); } // reconcile with active record activeConfiguration.getRecentProfiles().clear(); if (!(CollectionUtils.size(rpItems) == 1 && StringUtils.equalsIgnoreCase(rpItems.get(0).getText(), MI_NO_PROFILES.getText()))) { // there's more than just a < None > element activeConfiguration .setRecentProfiles(rpItems.stream().map((mi) -> mi.getText()).collect(Collectors.toList())); } // end #18 }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
private boolean validateSign() { if (logger.isDebugEnabled()) { logger.debug("[VALIDATE]"); }// www .j a v a 2s .co m boolean isValid = true; // // Validate the Source JAR field // if (StringUtils.isBlank(activeProfile.getSourceFileFileName())) { if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) { tfSourceFile.getStyleClass().add("tf-validation-error"); } isValid = false; } else { if (!new File(activeProfile.getSourceFileFileName()).exists()) { if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) { tfSourceFile.getStyleClass().add("tf-validation-error"); } Alert alert = new Alert(Alert.AlertType.ERROR, "Specified Source " + activeProfile.getArgsType() + " does not exist"); alert.showAndWait(); isValid = false; } } // // Validate the TargetJAR field // if (StringUtils.isBlank(activeProfile.getTargetFileFileName())) { if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) { tfTargetFile.getStyleClass().add("tf-validation-error"); } isValid = false; } if (activeProfile.getArgsType() == SigningArgumentsType.FOLDER) { if (StringUtils.equalsIgnoreCase(activeProfile.getSourceFileFileName(), activeProfile.getTargetFileFileName())) { if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) { tfTargetFile.getStyleClass().add("tf-validation-error"); } Alert alert = new Alert(Alert.AlertType.ERROR, "Source folder and target folder cannot be the same"); alert.showAndWait(); isValid = false; } } // // #13 Validate the Jarsigner Config form // String jarsignerConfigField = ""; String jarsignerConfigMessage = ""; if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeystore())) { jarsignerConfigField = "Keystore"; jarsignerConfigMessage = "A keystore must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigStorepass())) { jarsignerConfigField = "Storepass"; jarsignerConfigMessage = "A password for the keystore must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigAlias())) { jarsignerConfigField = "Alias"; jarsignerConfigMessage = "An alias for the key must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeypass())) { jarsignerConfigField = "Keypass"; jarsignerConfigMessage = "A password for the key must be specified"; } if (StringUtils.isNotEmpty(jarsignerConfigMessage)) { if (logger.isDebugEnabled()) { logger.debug("[VALIDATE] jarsigner config not valid {}", jarsignerConfigMessage); } Alert alert = new Alert(Alert.AlertType.ERROR, "Set " + jarsignerConfigField + " in Configure"); alert.setHeaderText(jarsignerConfigMessage); FlowPane fp = new FlowPane(); Label lbl = new Label("Set " + jarsignerConfigField + " in "); Hyperlink link = new Hyperlink("Configure"); fp.getChildren().addAll(lbl, link); link.setOnAction((evt) -> { alert.close(); openJarsignerConfig(); }); alert.getDialogPane().contentProperty().set(fp); alert.showAndWait(); isValid = false; } // // #38 check keystore prior to running // KeytoolCommand keytoolCommand = keytoolCommandProvider.get(); Task<Boolean> keytoolTask = new Task<Boolean>() { @Override protected Boolean call() throws Exception { final List<String> aliases = keytoolCommand.findAliases( activeConfiguration.getKeytoolCommand().toString(), activeProfile.getJarsignerConfigKeystore(), activeProfile.getJarsignerConfigStorepass()); if (logger.isDebugEnabled()) { logger.debug("[KEYTOOL] # aliases=" + CollectionUtils.size(aliases)); } return true; } }; new Thread(keytoolTask).start(); try { if (!keytoolTask.get()) { if (logger.isDebugEnabled()) { logger.debug("[KEYTOOL] keystore or configuration not valid"); } isValid = false; } } catch (InterruptedException | ExecutionException e) { isValid = false; logger.error("error accessing keystore", e); Alert alert = new Alert(Alert.AlertType.ERROR, e.getMessage() // contains formatted string ); alert.showAndWait(); } return isValid; }
From source file:nl.ucan.navigate.NestedPath.java
private NestedPath() { this.propertyInstance = new PropertyInstance() { public Object indexed(Object bean, String property, int index, Object value) { log.info("created indexed property " + property + " at " + index + " of bean " + bean + " and will be set to " + value); return value; }/*from w ww. ja v a 2 s. c o m*/ public Object simple(Object bean, String property, Object value) { log.info("created simple property " + property + " of bean " + bean + " and will be set to " + value); return value; } }; this.propertyValue = new PropertyValue() { public Object indexed(Object bean, String property, int index, Object value) { log.info("value of indexed property " + property + " at " + index + " of bean " + bean + " will be set to " + value); return value; } public Object mapped(Object bean, String property, Object key, Object value) { log.info("value of mapped property " + property + " at " + key + " of bean " + bean + " will be set to " + value); return value; } public Object simple(Object bean, String property, Object value) { log.info("value of simple property " + property + " of bean " + bean + " will be set to " + value); return value; } public Object valueOf(Class clasz, String property, String value) { log.info("value of valueOf " + property + " will be set to " + value); return value; } }; this.indexPointer = new IndexPointer() { public int size(Object bean) { return CollectionUtils.size(bean); } public Object get(Object bean, int idx) { return CollectionUtils.get(bean, idx); } public int firstIndexOf(Object bean, String undeterminedIndex) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException, IntrospectionException { this.setUndeterminedIndex(undeterminedIndex); for (int idx = 0; idx < size(bean); idx++) { Object object = get(bean, idx); if (object != null) { if (evaluate(object, this.getUndeterminedIndex())) return idx; } } return -1; } public void setIndexAsProperty(Object bean, String undeterminedIndex) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException, IntrospectionException { this.setUndeterminedIndex(undeterminedIndex); Object value = propertyValue.simple(bean, this.getProperty(), this.getValue()); pub.setProperty(bean, this.getProperty(), value); } private String undeterminedIndex; private void setUndeterminedIndex(String undeterminedIndex) { this.undeterminedIndex = undeterminedIndex; } private String getUndeterminedIndex() { return this.undeterminedIndex; } private boolean evaluate(Object bean, String undeterminedIndex) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException, IntrospectionException { this.setUndeterminedIndex(undeterminedIndex); String property = getProperty(); String valueOfIndex = getValue(); Object valueOfBean = pub.getProperty(bean, property); return ObjectUtils.equals(valueOfIndex, valueOfBean); } private String getProperty() { Map.Entry<String, String> entry = getNamedIndex(this.getUndeterminedIndex()); return entry.getKey(); } private String getValue() { Map.Entry<String, String> entry = getNamedIndex(this.getUndeterminedIndex()); return entry.getValue(); } private Map.Entry<String, String> getNamedIndex(String value) { final String SEP = "="; Map<String, String> keyValuePair = new HashMap<String, String>(); if (StringUtils.indexOf(value, SEP) == -1) return null; keyValuePair.put(StringUtils.substringBefore(value, SEP), StringUtils.substringAfter(value, SEP)); return keyValuePair.entrySet().iterator().next(); } }; this.pub = BeanUtilsBean.getInstance().getPropertyUtils(); this.pub.setResolver(new ResolverImpl()); }
From source file:org.akaza.openclinica.control.submit.VerifyImportedCRFDataServlet.java
@Override @SuppressWarnings(value = "unchecked") public void processRequest() throws Exception { ItemDataDAO itemDataDao = new ItemDataDAO(sm.getDataSource()); itemDataDao.setFormatDates(false);/*from www . ja v a 2 s .c om*/ EventCRFDAO eventCrfDao = new EventCRFDAO(sm.getDataSource()); CrfBusinessLogicHelper crfBusinessLogicHelper = new CrfBusinessLogicHelper(sm.getDataSource()); String action = request.getParameter("action"); FormProcessor fp = new FormProcessor(request); // checks which module the requests are from String module = fp.getString(MODULE); request.setAttribute(MODULE, module); resetPanel(); panel.setStudyInfoShown(false); panel.setOrderedData(true); setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering")); setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading")); setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version")); setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from")); setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from")); if ("confirm".equalsIgnoreCase(action)) { List<DisplayItemBeanWrapper> displayItemBeanWrappers = (List<DisplayItemBeanWrapper>) session .getAttribute("importedData"); logger.info("Size of displayItemBeanWrappers : " + displayItemBeanWrappers.size()); ImportCRFInfoContainer importCrfInfo = (ImportCRFInfoContainer) session.getAttribute("importCrfInfo"); for (DisplayItemBeanWrapper wrapper : displayItemBeanWrappers) { boolean resetSDV = false; EventCRFBean eventCrfBean = wrapper.getEventCrfBean(); if (!findCRFInfo(importCrfInfo, eventCrfBean)) { wrapper.setOverwrite(false); continue; } } forwardPage(Page.VERIFY_IMPORT_CRF_DATA); } if ("save".equalsIgnoreCase(action)) { // setup ruleSets to run if applicable RuleSetServiceInterface ruleSetService = (RuleSetServiceInterface) SpringServletAccess .getApplicationContext(context).getBean("ruleSetService"); List<ImportDataRuleRunnerContainer> containers = this.ruleRunSetup(sm.getDataSource(), currentStudy, ub, ruleSetService); List<DisplayItemBeanWrapper> displayItemBeanWrappers = (List<DisplayItemBeanWrapper>) session .getAttribute("importedData"); // System.out.println("Size of displayItemBeanWrappers : " + // displayItemBeanWrappers.size()); HashMap<String, String> importedCRFStatuses = (HashMap<String, String>) session .getAttribute("importedCRFStatuses"); ImportCRFInfoContainer importCrfInfo = (ImportCRFInfoContainer) session.getAttribute("importCrfInfo"); int skippedCRFCount = 0; for (DisplayItemBeanWrapper wrapper : displayItemBeanWrappers) { boolean resetSDV = false; EventCRFBean eventCrfBean = wrapper.getEventCrfBean(); if (!findCRFInfo(importCrfInfo, eventCrfBean)) { ++skippedCRFCount; continue; } String eventCRFStatus = importedCRFStatuses.get(eventCrfBean.getStudySubjectId() + "-" + eventCrfBean.getStudyEventId() + "-" + eventCrfBean.getFormLayoutId()); if (eventCRFStatus != null && !eventCRFStatus.equals(DataEntryStage.INITIAL_DATA_ENTRY.getName()) && !eventCRFStatus.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE.getName())) { continue; } if (eventCrfBean.getId() == 0) { eventCrfDao.create(eventCrfBean); } // TODO : tom , the wrapper object has all the necessary data - // as you see we check the // is to see if this data is Savable if it is then we go ahead // and save it. if not we discard. // So the change needs to happen here , instead of discarding we // need to file discrepancy notes // and save the data. If you look in the // Page.VERIFY_IMPORT_CRF_DATA jsp file you can see how I am // pulling the errors. and use that in the same way. logger.info("right before we check to make sure it is savable: " + wrapper.isSavable()); if (wrapper.isSavable()) { ArrayList<Integer> eventCrfInts = new ArrayList<Integer>(); // based on the use case: "If any of the data does not meet // validations specified in the CRF // Template, a discrepancy note is automatically logged. // The DN will have a type of Failed Validation Check, and // a message of Failed Validation check." // System.out.println("wrapper problems found : " + // wrapper.getValidationErrors().toString()); for (DisplayItemBean displayItemBean : wrapper.getDisplayItemBeans()) { displayItemBean.getData().setEventCRFId(eventCrfBean.getId()); logger.info("found value here: " + displayItemBean.getData().getValue()); logger.info("found status here: " + eventCrfBean.getStatus().getName()); // System.out.println("found event crf bean name here: " // + // eventCrfBean.getEventName()+" id "+eventCrfBean.getId // ()); // SO, items can be created in a wrapper which is set to // overwrite // we get around this by checking the bean first, to // make sure it's not null ItemDataBean itemDataBean = new ItemDataBean(); itemDataBean = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal( displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal()); if (wrapper.isOverwrite() && itemDataBean.getStatus() != null) { // ItemDataBean itemDataBean = new ItemDataBean(); // itemDataBean = // itemDataDao.findByItemIdAndEventCRFIdAndOrdinal( // displayItemBean.getItem().getId(), // eventCrfBean.getId(), displayItemBean // .getData().getOrdinal()); // itemDataBean = // itemDataDao.findByEventCRFIdAndItemName( // eventCrfBean, // displayItemBean.getItem().getName()); if (!itemDataBean.getValue().equals(displayItemBean.getData().getValue())) resetSDV = true; logger.info("just tried to find item data bean on item name " + displayItemBean.getItem().getName()); itemDataBean.setUpdatedDate(new Date()); itemDataBean.setUpdater(ub); itemDataBean.setValue(displayItemBean.getData().getValue()); // set status? itemDataDao.update(itemDataBean); logger.info("updated: " + itemDataBean.getItemId()); // need to set pk here in order to create dn displayItemBean.getData().setId(itemDataBean.getId()); } else { resetSDV = true; itemDataDao.create(displayItemBean.getData()); logger.info("created: " + displayItemBean.getData().getItemId() + "event CRF ID = " + eventCrfBean.getId() + "CRF VERSION ID =" + eventCrfBean.getCRFVersionId()); // does this dao function work for repeating // events/groups? // ItemDataBean itemDataBean = // itemDataDao.findByEventCRFIdAndItemName( // eventCrfBean, // displayItemBean.getItem().getName()); ItemDataBean itemDataBean2 = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal( displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal()); logger.info("found: id " + itemDataBean2.getId() + " name " + itemDataBean2.getName()); displayItemBean.getData().setId(itemDataBean2.getId()); } // logger.info("created item data bean: // "+displayItemBean.getData().getId()); // logger.info("created: // "+displayItemBean.getData().getName()); // logger.info("continued: // "+displayItemBean.getData().getItemId()); ItemDAO idao = new ItemDAO(sm.getDataSource()); ItemBean ibean = (ItemBean) idao.findByPK(displayItemBean.getData().getItemId()); // logger.info("continued2: getName " + // ibean.getName()); // System.out.println("*** checking for validation errors: " // + ibean.getName()); String itemOid = displayItemBean.getItem().getOid() + "_" + wrapper.getStudyEventRepeatKey() + "_" + displayItemBean.getData().getOrdinal() + "_" + wrapper.getStudySubjectOid(); if (wrapper.getValidationErrors().containsKey(itemOid)) { ArrayList messageList = (ArrayList) wrapper.getValidationErrors().get(itemOid); // if // (wrapper.getValidationErrors().containsKey(ibean // .getName())) { // ArrayList messageList = (ArrayList) // wrapper.getValidationErrors // ().get(ibean.getName()); // could be more then one will have to iterate // could it be more than one? tbh 08/2008 for (int iter = 0; iter < messageList.size(); iter++) { String message = (String) messageList.get(iter); DiscrepancyNoteBean parentDn = ImportSpringJob.createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, null, ub, sm.getDataSource(), currentStudy); ImportSpringJob.createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, parentDn.getId(), ub, sm.getDataSource(), currentStudy); // System.out.println("*** created disc note with message: " // + message); // displayItemBean); } } // logger.info("created: // "+displayItemBean.getDbData().getName()); if (eventCRFStatus != null && eventCRFStatus.equals(DataEntryStage.INITIAL_DATA_ENTRY.getName()) && eventCrfBean.getStatus().isAvailable()) { crfBusinessLogicHelper.markCRFStarted(eventCrfBean, ub); } else { crfBusinessLogicHelper.markCRFComplete(eventCrfBean, ub); } } // Reset the SDV status if item data has been changed or added if (eventCrfBean != null && resetSDV) eventCrfDao.setSDVStatus(false, ub.getId(), eventCrfBean.getId()); // end of item datas, tbh // crfBusinessLogicHelper.markCRFComplete(eventCrfBean, ub); // System .out.println("*** just updated event crf bean: "+ // eventCrfBean.getId()); // need to update the study event status as well, tbh // crfBusinessLogicHelper.updateStudyEvent(eventCrfBean, // ub); // above should do it for us, tbh 08/2008 } } if (CollectionUtils.size(displayItemBeanWrappers) == skippedCRFCount) addPageMessage(respage.getString("no_data_has_been_imported")); else addPageMessage(respage.getString("data_has_been_successfully_import")); addPageMessage(this.ruleActionWarnings( this.runRules(currentStudy, ub, containers, ruleSetService, ExecutionMode.SAVE))); // forwardPage(Page.SUBMIT_DATA_SERVLET); forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET); // replaced tbh, 06/2009 } }
From source file:org.apache.atlas.repository.store.graph.AtlasTypeDefGraphStore.java
@Override @GraphTransaction/*from w ww .j a va2 s . c o m*/ public AtlasTypesDef createTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug( "==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classifications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs())); } AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit(); tryTypeCreation(typesDef, ttr); AtlasTypesDef ret = addToGraphStore(typesDef, ttr); if (LOG.isDebugEnabled()) { LOG.debug( "<== AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs())); } return ret; }
From source file:org.apache.atlas.repository.store.graph.AtlasTypeDefGraphStore.java
@Override @GraphTransaction// w w w. ja va2 s . co m public AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug( "==> AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs())); } AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit(); // Translate any NOT FOUND errors to BAD REQUEST try { ttr.updateTypes(typesDef); } catch (AtlasBaseException e) { if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode()) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage()); } else { throw e; } } AtlasTypesDef ret = updateGraphStore(typesDef, ttr); if (LOG.isDebugEnabled()) { LOG.debug( "<== AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs())); } return ret; }
From source file:org.apache.atlas.repository.store.graph.AtlasTypeDefGraphStore.java
@Override @GraphTransaction/* www . j a va2s. c o m*/ public void deleteTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug( "==> AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs())); } AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit(); AtlasEnumDefStore enumDefStore = getEnumDefStore(ttr); AtlasStructDefStore structDefStore = getStructDefStore(ttr); AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr); AtlasEntityDefStore entityDefStore = getEntityDefStore(ttr); List<Object> preDeleteStructDefs = new ArrayList<>(); List<Object> preDeleteClassifiDefs = new ArrayList<>(); List<Object> preDeleteEntityDefs = new ArrayList<>(); if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { for (AtlasStructDef structDef : typesDef.getStructDefs()) { if (StringUtils.isNotBlank(structDef.getGuid())) { preDeleteStructDefs.add(structDefStore.preDeleteByGuid(structDef.getGuid())); } else { preDeleteStructDefs.add(structDefStore.preDeleteByName(structDef.getName())); } } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) { if (StringUtils.isNotBlank(classifiDef.getGuid())) { preDeleteClassifiDefs.add(classifiDefStore.preDeleteByGuid(classifiDef.getGuid())); } else { preDeleteClassifiDefs.add(classifiDefStore.preDeleteByName(classifiDef.getName())); } } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { if (StringUtils.isNotBlank(entityDef.getGuid())) { preDeleteEntityDefs.add(entityDefStore.preDeleteByGuid(entityDef.getGuid())); } else { preDeleteEntityDefs.add(entityDefStore.preDeleteByName(entityDef.getName())); } } } if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { int i = 0; for (AtlasStructDef structDef : typesDef.getStructDefs()) { if (StringUtils.isNotBlank(structDef.getGuid())) { structDefStore.deleteByGuid(structDef.getGuid(), preDeleteStructDefs.get(i)); } else { structDefStore.deleteByName(structDef.getName(), preDeleteStructDefs.get(i)); } i++; } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { int i = 0; for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) { if (StringUtils.isNotBlank(classifiDef.getGuid())) { classifiDefStore.deleteByGuid(classifiDef.getGuid(), preDeleteClassifiDefs.get(i)); } else { classifiDefStore.deleteByName(classifiDef.getName(), preDeleteClassifiDefs.get(i)); } i++; } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { int i = 0; for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { if (StringUtils.isNotBlank(entityDef.getGuid())) { entityDefStore.deleteByGuid(entityDef.getGuid(), preDeleteEntityDefs.get(i)); } else { entityDefStore.deleteByName(entityDef.getName(), preDeleteEntityDefs.get(i)); } i++; } } if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) { for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) { if (StringUtils.isNotBlank(enumDef.getGuid())) { enumDefStore.deleteByGuid(enumDef.getGuid()); } else { enumDefStore.deleteByName(enumDef.getName()); } } } // Remove all from ttr.removeTypesDef(typesDef); if (LOG.isDebugEnabled()) { LOG.debug( "<== AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs())); } }
From source file:org.apache.ranger.plugin.store.file.TagFileStore.java
@Override public RangerTag getTag(Long id) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> TagFileStore.getTag(" + id + ")"); }/*from w ww . j av a2 s . c o m*/ RangerTag ret = null; if (id != null) { SearchFilter filter = new SearchFilter(SearchFilter.TAG_ID, id.toString()); List<RangerTag> tags = getTags(filter); if (CollectionUtils.isNotEmpty(tags) && CollectionUtils.size(tags) == 1) { ret = tags.get(0); } } if (LOG.isDebugEnabled()) { LOG.debug("<== TagFileStore.getTagDef(" + id + "): " + ret); } return ret; }