List of usage examples for org.apache.commons.lang BooleanUtils isTrue
public static boolean isTrue(Boolean bool)
Checks if a Boolean
value is true
, handling null
by returning false
.
BooleanUtils.isTrue(Boolean.TRUE) = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null) = false
From source file:jp.primecloud.auto.process.lb.PuppetLoadBalancerProcess.java
protected void configureInstance(Long loadBalancerNo, Long componentNo, Long instanceNo, Map<String, Object> rootMap) { LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); Component component = componentDao.read(componentNo); Instance instance = instanceDao.read(instanceNo); // /*from ww w . ja v a2 s . co m*/ Map<String, Object> instanceMap = createInstanceMap(instanceNo); rootMap.putAll(instanceMap); // ComponentType componentType = componentTypeDao.read(component.getComponentTypeNo()); File manifestFile = new File(manifestDir, instance.getFqdn() + "." + component.getComponentName() + ".pp"); // ? restoreManifest(manifestFile); // ???? String digest = getFileDigest(manifestFile, "UTF-8"); // ?????????? if (digest == null && BooleanUtils.isNotTrue(loadBalancer.getEnabled())) { return; } // ?? String templateName = "loadBalancer_" + componentType.getComponentTypeName() + ".ftl"; generateManifest(templateName, rootMap, manifestFile, "UTF-8"); // ????? if (digest != null) { String newDigest = getFileDigest(manifestFile, "UTF-8"); if (digest.equals(newDigest)) { // ????? if (log.isDebugEnabled()) { log.debug(MessageUtils.format("Not changed manifest.(file={0})", manifestFile.getName())); } return; } } // Puppet? try { runPuppet(instance, component); } finally { if (BooleanUtils.isTrue(loadBalancer.getEnabled())) { // ?? backupManifest(manifestFile); } else { // ? deleteManifest(manifestFile); } } }
From source file:com.haulmont.cuba.gui.components.filter.condition.DynamicAttributesCondition.java
@Override protected void updateText() { if (operator == Op.NOT_EMPTY) { if (BooleanUtils.isTrue((Boolean) param.getValue())) { text = text.replace("not exists", "exists"); } else if (BooleanUtils.isFalse((Boolean) param.getValue()) && !text.contains("not exists")) { text = text.replace("exists ", "not exists "); }//from ww w. j a v a 2 s . c o m } if (!isCollection) { if (operator == Op.ENDS_WITH || operator == Op.STARTS_WITH || operator == Op.CONTAINS || operator == Op.DOES_NOT_CONTAIN) { Matcher matcher = LIKE_PATTERN.matcher(text); if (matcher.find()) { String escapeCharacter = ("\\".equals(QueryUtils.ESCAPE_CHARACTER) || "$".equals(QueryUtils.ESCAPE_CHARACTER)) ? QueryUtils.ESCAPE_CHARACTER + QueryUtils.ESCAPE_CHARACTER : QueryUtils.ESCAPE_CHARACTER; text = matcher.replaceAll("$1 ESCAPE '" + escapeCharacter + "' "); } } } else { if (operator == Op.CONTAINS) { text = text.replace("not exists", "exists"); } else if (operator == Op.DOES_NOT_CONTAIN && !text.contains("not exists")) { text = text.replace("exists ", "not exists "); } } }
From source file:com.naver.blog.functionalservice.search.QueryParameter.java
public Map<String, String> getParamters() { Map<String, String> parameters = new HashMap<String, String>(); // /*from www .jav a 2s . com*/ safeAddToMapIfKeyOrValueIsBlank(parameters, "version", "1.0.0"); safeAddToMapIfKeyOrValueIsBlank(parameters, "q_enc", "utf-8"); safeAddToMapIfKeyOrValueIsBlank(parameters, "r_enc", "utf-8"); safeAddToMapIfKeyOrValueIsBlank(parameters, "r_format", "xml"); safeAddToMapIfKeyOrValueIsBlank(parameters, "ic", "post"); safeAddToMapIfKeyOrValueIsBlank(parameters, "gk_adt", isAdult == null ? "0" : BooleanUtils.isTrue(isAdult) ? "0" : "1"); safeAddToMapIfKeyOrValueIsBlank(parameters, "gk_fbd", isForbidden == null ? "0" : BooleanUtils.isTrue(isForbidden) ? "0" : "1"); safeAddToMapIfKeyOrValueIsBlank(parameters, "gk_qvt", "0"); // query safeAddToMapIfKeyOrValueIsBlank(parameters, "q", query); // safeAddToMapIfKeyOrValueIsBlank(parameters, "st_blogno", blogNo == null ? null : "exist:" + blogNo); safeAddToMapIfKeyOrValueIsBlank(parameters, "display", (page != null && page.getCountPerPage() != null) ? String.valueOf(page.getCountPerPage()) : null); safeAddToMapIfKeyOrValueIsBlank(parameters, "start", (page == null || page.getRowCountToObatinBasicRow() == null) ? 1 : page.getRowCountToObatinBasicRow() + 1); safeAddToMapIfKeyOrValueIsBlank(parameters, "rp", makeResultProcessingType(contentLength)); safeAddToMapIfKeyOrValueIsBlank(parameters, "r_psglen", makeLength(titleLength, contentLength)); safeAddToMapIfKeyOrValueIsBlank(parameters, "st_adddate", makeAddDate(calcStartDate(termType, startDate), calcEndDate(termType, endDate))); // {@link ParameterType} safeParameterTypeAddToMapIfKeyOrValueIsBlank(parameters, "pr", presentationCodeType); safeParameterTypeAddToMapIfKeyOrValueIsBlank(parameters, "st", searchTargetAsCollectionType); safeParameterTypeAddToMapIfKeyOrValueIsBlank(parameters, "sm", searchMehtodType); safeParameterTypeAddToMapIfKeyOrValueIsBlank(parameters, "so", sortType); safeParameterTypeAddToMapIfKeyOrValueIsBlank(parameters, "hl", highLightType); safeParameterTypeAddToMapIfKeyOrValueIsBlank(parameters, "st_openmode", QueryOpenType.find(relationType)); return parameters; }
From source file:com.haulmont.restapi.service.EntitiesControllerManager.java
public EntitiesSearchResult searchEntities(String entityName, String filterJson, @Nullable String viewName, @Nullable Integer limit, @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls, @Nullable Boolean returnCount, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion) { if (filterJson == null) { throw new RestAPIException("Cannot parse entities filter", "Entities filter cannot be null", HttpStatus.BAD_REQUEST); }/*from w ww. j av a 2 s. co m*/ entityName = restControllerUtils.transformEntityNameIfRequired(entityName, modelVersion, JsonTransformationDirection.FROM_VERSION); MetaClass metaClass = restControllerUtils.getMetaClass(entityName); checkCanReadEntity(metaClass); RestFilterParseResult filterParseResult; try { filterParseResult = restFilterParser.parse(filterJson, metaClass); } catch (RestFilterParseException e) { throw new RestAPIException("Cannot parse entities filter", e.getMessage(), HttpStatus.BAD_REQUEST, e); } String jpqlWhere = filterParseResult.getJpqlWhere().replace("{E}", "e"); Map<String, Object> queryParameters = filterParseResult.getQueryParameters(); String queryString = "select e from " + entityName + " e where " + jpqlWhere; String json = _loadEntitiesList(queryString, viewName, limit, offset, sort, returnNulls, dynamicAttributes, modelVersion, metaClass, queryParameters); Long count = null; if (BooleanUtils.isTrue(returnCount)) { LoadContext ctx = LoadContext.create(metaClass.getJavaClass()) .setQuery(LoadContext.createQuery(queryString).setParameters(queryParameters)); count = dataManager.getCount(ctx); } return new EntitiesSearchResult(json, count); }
From source file:jp.primecloud.auto.process.ProcessManager.java
protected boolean processStartInstances(final Farm farm) { // ??????/*from w ww . jav a 2 s . co m*/ if (BooleanUtils.isTrue(farm.getComponentProcessing())) { return false; } // ?????????????????????? boolean coodinated = true; List<Instance> allInstances = instanceDao.readByFarmNo(farm.getFarmNo()); for (Instance instance : allInstances) { if (InstanceStatus.fromStatus(instance.getStatus()) == InstanceStatus.RUNNING) { if (BooleanUtils.isTrue(instance.getEnabled())) { if (InstanceCoodinateStatus .fromStatus(instance.getCoodinateStatus()) == InstanceCoodinateStatus.UN_COODINATED) { coodinated = false; break; } } } } // ???????????? if (!coodinated) { final User user = userDao.read(farm.getUserNo()); Runnable runnable = new Runnable() { @Override public void run() { LoggingUtils.setUserNo(user.getMasterUser()); LoggingUtils.setUserName(user.getUsername()); LoggingUtils.setFarmNo(farm.getFarmNo()); LoggingUtils.setFarmName(farm.getFarmName()); LoggingUtils.setLoginUserNo(user.getUserNo()); try { instancesProcess.start(farm.getFarmNo()); } catch (MultiCauseException ignore) { } catch (Throwable e) { log.error(e.getMessage(), e); // eventLogger.error("SystemError", new Object[] { e.getMessage() }); } finally { LoggingUtils.removeContext(); } } }; executorService.execute(runnable); } return coodinated; }
From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java
/** * {@inheritDoc}//from ww w.j a va2s .c om */ @Override public void startComponents(Long farmNo, List<Long> componentNos) { // ???? List<ComponentInstance> componentInstances = componentInstanceDao.readInComponentNos(componentNos); boolean skipServer = false; Long skipInstanceNo = null; for (ComponentInstance componentInstance : componentInstances) { if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) { // ???????? if (BooleanUtils.isTrue(componentInstance.getEnabled()) || BooleanUtils.isNotTrue(componentInstance.getConfigure())) { componentInstance.setEnabled(false); componentInstance.setConfigure(true); componentInstanceDao.update(componentInstance); } continue; } Instance instance = instanceDao.read(componentInstance.getInstanceNo()); Platform platform = platformDao.read(instance.getPlatformNo()); if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { PlatformAws platformAws = platformAwsDao.read(instance.getPlatformNo()); AwsInstance awsInstance = awsInstanceDao.read(instance.getInstanceNo()); if (platformAws.getVpc() && StringUtils.isEmpty(awsInstance.getSubnetId())) { //EC2+VPC???????????? continue; } } if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { AzureInstance azureInstance = azureInstanceDao.read(instance.getInstanceNo()); if (StringUtils.isEmpty(azureInstance.getSubnetId())) { //??????????? continue; } // ??????2???? // ?No??? if (StringUtils.isEmpty(azureInstance.getInstanceName()) && skipServer == true && azureInstance.getInstanceNo().equals(skipInstanceNo) == false) { continue; } // ??????1?? if (StringUtils.isEmpty(azureInstance.getInstanceName()) && skipServer == false) { skipServer = true; skipInstanceNo = azureInstance.getInstanceNo(); } } if (BooleanUtils.isNotTrue(componentInstance.getEnabled()) || BooleanUtils.isNotTrue(componentInstance.getConfigure())) { componentInstance.setEnabled(true); componentInstance.setConfigure(true); componentInstanceDao.update(componentInstance); } } // ?????? Set<Long> instanceNos = new LinkedHashSet<Long>(); for (ComponentInstance componentInstance : componentInstances) { instanceNos.add(componentInstance.getInstanceNo()); } List<Instance> instances = instanceDao.readInInstanceNos(instanceNos); boolean skipServer2 = false; for (Instance instance : instances) { Platform platform = platformDao.read(instance.getPlatformNo()); if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { PlatformAws platformAws = platformAwsDao.read(instance.getPlatformNo()); AwsInstance awsInstance = awsInstanceDao.read(instance.getInstanceNo()); if (platformAws.getVpc() && StringUtils.isEmpty(awsInstance.getSubnetId())) { //EC2+VPC???????????? continue; } } if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { AzureInstance azureInstance = azureInstanceDao.read(instance.getInstanceNo()); if (StringUtils.isEmpty(azureInstance.getSubnetId())) { //??????????? continue; } // ??????2???? if (StringUtils.isEmpty(azureInstance.getInstanceName()) && skipServer2 == true) { continue; } // ??????1?? if (StringUtils.isEmpty(azureInstance.getInstanceName()) && skipServer2 == false) { skipServer2 = true; } } if (BooleanUtils.isNotTrue(instance.getEnabled())) { instance.setEnabled(true); instanceDao.update(instance); } } // ???? scheduleFarm(farmNo); }
From source file:jp.primecloud.auto.service.impl.FarmServiceImpl.java
/** * {@inheritDoc}//from ww w. ja v a2 s .c om */ @Override public Long createFarm(Long userNo, String farmName, String comment) { // ? if (userNo == null) { throw new AutoApplicationException("ECOMMON-000003", "userNo"); } if (farmName == null || farmName.length() == 0) { throw new AutoApplicationException("ECOMMON-000003", "farmName"); } // ?? if (!Pattern.matches("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", farmName)) { throw new AutoApplicationException("ECOMMON-000012", "farmName"); } // TODO: ?? // ????? Farm checkFarm = farmDao.readByFarmName(farmName); if (checkFarm != null) { // ??????? throw new AutoApplicationException("ESERVICE-000201", farmName); } // ??? // TODO: ??????? String domainName = farmName + "." + Config.getProperty("dns.domain"); // ?? Farm farm = new Farm(); farm.setFarmName(farmName); farm.setUserNo(userNo); farm.setComment(comment); farm.setDomainName(domainName); farm.setScheduled(false); farm.setComponentProcessing(false); farmDao.create(farm); List<Platform> platforms = platformDao.readAll(); for (Platform platform : platforms) { // TODO CLOUD BRANCHING // VMware?? if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) { if (vmwareKeyPairDao.countByUserNoAndPlatformNo(userNo, platform.getPlatformNo()) > 0) { // ???VLAN? VmwareNetwork publicNetwork = null; VmwareNetwork privateNetwork = null; List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao .readByPlatformNo(platform.getPlatformNo()); for (VmwareNetwork vmwareNetwork : vmwareNetworks) { if (vmwareNetwork.getFarmNo() != null) { continue; } if (BooleanUtils.isTrue(vmwareNetwork.getPublicNetwork())) { if (publicNetwork == null) { publicNetwork = vmwareNetwork; } } else { if (privateNetwork == null) { privateNetwork = vmwareNetwork; } } } // VLAN? if (publicNetwork != null) { publicNetwork.setFarmNo(farm.getFarmNo()); vmwareNetworkDao.update(publicNetwork); } if (privateNetwork != null) { privateNetwork.setFarmNo(farm.getFarmNo()); vmwareNetworkDao.update(privateNetwork); } } // VCloud?? } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { //????????????vApp?? if (BooleanUtils.isTrue(platform.getSelectable()) && vcloudCertificateDao.countByUserNoAndPlatformNo(userNo, platform.getPlatformNo()) > 0 && vcloudKeyPairDao.countByUserNoAndPlatformNo(userNo, platform.getPlatformNo()) > 0) { //vApp? IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(userNo, platform.getPlatformNo()); gateway.createMyCloud(farmName); } // Azure?? } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { // ???? // OpenStack?? } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) { // ???? } } // VCloud?(iaasGateWay??????)??Zabbix???????? // ???? Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix")); if (BooleanUtils.isTrue(useZabbix)) { zabbixHostProcess.createFarmHostgroup(farm.getFarmNo()); } // eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farmName, null, null, null, null, "FarmCreate", null, null, null); return farm.getFarmNo(); }
From source file:com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler.java
@Override public TaskWorkBucketProcessingResult run(Task localCoordinatorTask, WorkBucketType workBucket, TaskWorkBucketProcessingResult previousRunResult) { String handlerUri = localCoordinatorTask.getHandlerUri(); Stage stage = getStage(handlerUri);//from w ww. j ava2 s . c o m LOGGER.trace("ReconciliationTaskHandler.run starting (stage: {})", stage); ReconciliationTaskResult reconResult = new ReconciliationTaskResult(); if (BooleanUtils.isTrue(localCoordinatorTask .getExtensionPropertyRealValue(SchemaConstants.MODEL_EXTENSION_FINISH_OPERATIONS_ONLY))) { if (stage == Stage.ALL) { stage = Stage.FIRST; } else { throw new IllegalStateException("Finish operations only selected for wrong stage: " + stage); } } OperationResult opResult = new OperationResult(OperationConstants.RECONCILIATION); opResult.setStatus(OperationResultStatus.IN_PROGRESS); TaskWorkBucketProcessingResult runResult = new TaskWorkBucketProcessingResult(); runResult.setOperationResult(opResult); if (previousRunResult != null) { runResult.setProgress(previousRunResult.getProgress()); AbstractSearchIterativeTaskHandler.logPreviousResultIfNeeded(localCoordinatorTask, previousRunResult, LOGGER); // temporary } runResult.setShouldContinue(false); // overridden later runResult.setBucketComplete(false); // overridden later String resourceOid = localCoordinatorTask.getObjectOid(); opResult.addContext("resourceOid", resourceOid); if (localCoordinatorTask.getChannel() == null) { localCoordinatorTask.setChannel(SchemaConstants.CHANGE_CHANNEL_RECON_URI); } if (resourceOid == null) { throw new IllegalArgumentException("Resource OID is missing in task extension"); } PrismObject<ResourceType> resource; ObjectClassComplexTypeDefinition objectclassDef; try { resource = provisioningService.getObject(ResourceType.class, resourceOid, null, localCoordinatorTask, opResult); RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, LayerType.MODEL, prismContext); objectclassDef = Utils.determineObjectClass(refinedSchema, localCoordinatorTask); } catch (ObjectNotFoundException ex) { // This is bad. The resource does not exist. Permanent problem. processErrorPartial(runResult, "Resource does not exist, OID: " + resourceOid, ex, TaskRunResultStatus.PERMANENT_ERROR, opResult); return runResult; } catch (CommunicationException ex) { // Error, but not critical. Just try later. processErrorPartial(runResult, "Communication error", ex, TaskRunResultStatus.TEMPORARY_ERROR, opResult); return runResult; } catch (SchemaException ex) { // Not sure about this. But most likely it is a misconfigured resource or connector // It may be worth to retry. Error is fatal, but may not be permanent. processErrorPartial(runResult, "Error dealing with schema", ex, TaskRunResultStatus.TEMPORARY_ERROR, opResult); return runResult; } catch (RuntimeException ex) { // Can be anything ... but we can't recover from that. // It is most likely a programming error. Does not make much sense // to retry. processErrorPartial(runResult, "Internal Error", ex, TaskRunResultStatus.PERMANENT_ERROR, opResult); return runResult; } catch (ConfigurationException ex) { // Not sure about this. But most likely it is a misconfigured resource or connector // It may be worth to retry. Error is fatal, but may not be permanent. processErrorPartial(runResult, "Configuration error", ex, TaskRunResultStatus.TEMPORARY_ERROR, opResult); return runResult; } catch (SecurityViolationException ex) { processErrorPartial(runResult, "Security violation", ex, TaskRunResultStatus.PERMANENT_ERROR, opResult); return runResult; } catch (ExpressionEvaluationException ex) { processErrorPartial(runResult, "Expression error", ex, TaskRunResultStatus.PERMANENT_ERROR, opResult); return runResult; } if (objectclassDef == null) { processErrorPartial(runResult, "Reconciliation without an object class specification is not supported", null, TaskRunResultStatus.PERMANENT_ERROR, opResult); return runResult; } reconResult.setResource(resource); reconResult.setObjectclassDefinition(objectclassDef); LOGGER.info( "Start executing reconciliation of resource {}, reconciling object class {}, stage: {}, work bucket: {}", resource, objectclassDef, stage, workBucket); long reconStartTimestamp = clock.currentTimeMillis(); AuditEventRecord requestRecord = new AuditEventRecord(AuditEventType.RECONCILIATION, AuditEventStage.REQUEST); requestRecord.setTarget(resource); requestRecord.setMessage("Stage: " + stage + ", Work bucket: " + workBucket); auditService.audit(requestRecord, localCoordinatorTask); try { if (isStage(stage, Stage.FIRST) && !scanForUnfinishedOperations(localCoordinatorTask, resourceOid, reconResult, opResult)) { processInterruption(runResult, resource, localCoordinatorTask, opResult); // appends also "last N failures" (TODO refactor) return runResult; } } catch (SchemaException ex) { // Not sure about this. But most likely it is a misconfigured resource or connector // It may be worth to retry. Error is fatal, but may not be permanent. processErrorPartial(runResult, "Error dealing with schema", ex, TaskRunResultStatus.TEMPORARY_ERROR, opResult); } catch (RuntimeException ex) { // Can be anything ... but we can't recover from that. // It is most likely a programming error. Does not make much sense // to retry. processErrorFinal(runResult, "Internal Error", ex, TaskRunResultStatus.PERMANENT_ERROR, resource, localCoordinatorTask, opResult); return runResult; } if (stage == Stage.ALL) { setExpectedTotalToNull(localCoordinatorTask, opResult); // expected total is unknown for the remaining phases } long beforeResourceReconTimestamp = clock.currentTimeMillis(); long afterResourceReconTimestamp; long afterShadowReconTimestamp; try { if (isStage(stage, Stage.SECOND) && !performResourceReconciliation(resource, objectclassDef, reconResult, localCoordinatorTask, workBucket, opResult)) { processInterruption(runResult, resource, localCoordinatorTask, opResult); return runResult; } afterResourceReconTimestamp = clock.currentTimeMillis(); if (isStage(stage, Stage.THIRD) && !performShadowReconciliation(resource, objectclassDef, reconStartTimestamp, afterResourceReconTimestamp, reconResult, localCoordinatorTask, workBucket, opResult)) { processInterruption(runResult, resource, localCoordinatorTask, opResult); return runResult; } afterShadowReconTimestamp = clock.currentTimeMillis(); } catch (ObjectNotFoundException ex) { // This is bad. The resource does not exist. Permanent problem. processErrorFinal(runResult, "Resource does not exist, OID: " + resourceOid, ex, TaskRunResultStatus.PERMANENT_ERROR, resource, localCoordinatorTask, opResult); return runResult; } catch (CommunicationException ex) { // Error, but not critical. Just try later. processErrorFinal(runResult, "Communication error", ex, TaskRunResultStatus.TEMPORARY_ERROR, resource, localCoordinatorTask, opResult); return runResult; } catch (SchemaException ex) { // Not sure about this. But most likely it is a misconfigured resource or connector // It may be worth to retry. Error is fatal, but may not be permanent. processErrorFinal(runResult, "Error dealing with schema", ex, TaskRunResultStatus.TEMPORARY_ERROR, resource, localCoordinatorTask, opResult); return runResult; } catch (RuntimeException ex) { // Can be anything ... but we can't recover from that. // It is most likely a programming error. Does not make much sense // to retry. processErrorFinal(runResult, "Internal Error", ex, TaskRunResultStatus.PERMANENT_ERROR, resource, localCoordinatorTask, opResult); return runResult; } catch (ConfigurationException ex) { // Not sure about this. But most likely it is a misconfigured resource or connector // It may be worth to retry. Error is fatal, but may not be permanent. processErrorFinal(runResult, "Configuration error", ex, TaskRunResultStatus.TEMPORARY_ERROR, resource, localCoordinatorTask, opResult); return runResult; } catch (SecurityViolationException ex) { processErrorFinal(runResult, "Security violation", ex, TaskRunResultStatus.PERMANENT_ERROR, resource, localCoordinatorTask, opResult); return runResult; } catch (ExpressionEvaluationException ex) { processErrorFinal(runResult, "Expression error", ex, TaskRunResultStatus.PERMANENT_ERROR, resource, localCoordinatorTask, opResult); return runResult; } opResult.computeStatus(); // This "run" is finished. But the task goes on ... runResult.setRunResultStatus(TaskRunResultStatus.FINISHED); runResult.setShouldContinue(true); runResult.setBucketComplete(true); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Reconciliation.run stopping, result: {}", opResult.getStatus()); } AuditEventRecord executionRecord = new AuditEventRecord(AuditEventType.RECONCILIATION, AuditEventStage.EXECUTION); executionRecord.setTarget(resource); executionRecord.setOutcome(OperationResultStatus.SUCCESS); executionRecord.setMessage(requestRecord.getMessage()); auditService.audit(executionRecord, localCoordinatorTask); long reconEndTimestamp = clock.currentTimeMillis(); long etime = reconEndTimestamp - reconStartTimestamp; long unOpsTime = beforeResourceReconTimestamp - reconStartTimestamp; long resourceReconTime = afterResourceReconTimestamp - beforeResourceReconTimestamp; long shadowReconTime = afterShadowReconTimestamp - afterResourceReconTimestamp; LOGGER.info( "Done executing reconciliation of resource {}, object class {}, Etime: {} ms (un-ops: {}, resource: {}, shadow: {})", resource, objectclassDef, etime, unOpsTime, resourceReconTime, shadowReconTime); reconResult.setRunResult(runResult); if (reconciliationTaskResultListener != null) { reconciliationTaskResultListener.process(reconResult); } TaskHandlerUtil.appendLastFailuresInformation(OperationConstants.RECONCILIATION, localCoordinatorTask, opResult); return runResult; }
From source file:com.haulmont.ext.web.ui.CauseGIBDD.CauseGIBDDBrowser.java
@Override public void init(Map<String, Object> params) { super.init(params); //? ? ? :/*from www . jav a 2s . com*/ docsTable.setMultiSelect(true); isTemplate = false; TableActionsHelper helper = new TableActionsHelper(this, docsTable); helper.createRefreshAction(); // ?, ? ?? ? ? ?? ? // ? , ?? ??. docsTable.addAction(new CreateAction()); docsTable.addAction(new RemoveCardNullChildAction("remove", this, docsTable)); docsTable.addAction(new EditAction()); docsTable.addAction(new RefreshAction(docsTable)); docsTable.addAction(new ThesisExcelAction(docsTable, new WebExportDisplay(), genericFilter)); // ? ? docsTable.addAction(new DeleteNotification()); cards = docflow_CardService.getCardsForCurrentUserActor(); final Action removeAction = docsTable.getAction("remove"); final TaskmanService taskmanService = ServiceLocator.lookup(TaskmanService.NAME); docsDs.addListener(new CollectionDsListenerAdapter() { @Override public void itemChanged(Datasource ds, Entity prevItem, Entity item) { super.itemChanged(ds, prevItem, item); if (editAction != null && editAction.getOwner() != null) ((Button) editAction.getOwner()).setEnabled(item != null); if (item == null) return; // ADMINISTRATOR_ROLE can remove any task, the CREATOR, // NOT INITIATOR only not sent on process Card card = (Card) ds.getItem(); User subCreator = card.getSubstitutedCreator(); User currentUser = UserSessionClient.getUserSession().getCurrentOrSubstitutedUser(); Set<Card> selected = docsTable.getSelected(); boolean allowRemove = true; if (selected.size() > 1) { for (Card c : selected) { if (taskmanService.isCurrentUserAdministrator()) { break; } else if (!(currentUser.equals(c.getSubstitutedCreator()) && (StringUtils.isBlank(c.getState()) || WfUtils.isCardInState(c, "New")))) { allowRemove = false; break; } } removeAction.setEnabled(allowRemove); if (removeAction.getOwner() != null) ((Button) removeAction.getOwner()).setEnabled(allowRemove); } else { allowRemove = taskmanService.isCurrentUserAdministrator() || (currentUser.equals(subCreator) && (StringUtils.isBlank(((Card) ds.getItem()).getState()) || WfUtils.isCardInState((Card) ds.getItem(), "New"))); removeAction.setEnabled(allowRemove); if (removeAction.getOwner() != null) ((Button) removeAction.getOwner()).setEnabled(allowRemove); } if ((showResolutions != null) && BooleanUtils.isTrue((Boolean) showResolutions.getValue()) && (item == null || docsTable.getSelected().size() < 2)) { String currentTab = tabsheet.getTab().getName(); if (currentTab.equals("resolutionsTab") && resolutionsFrame != null) resolutionsFrame.setCard((Card) item); if (currentTab.equals("hierarchyTab") && cardTreeFrame != null) cardTreeFrame.setCard((Card) item); } } @Override public void stateChanged(Datasource ds, Datasource.State prevState, Datasource.State state) { if (removeAction != null && removeAction.getOwner() != null) ((Button) removeAction.getOwner()) .setEnabled(Datasource.State.VALID.equals(state) && ds.getItem() != null); if (editAction != null && editAction.getOwner() != null) ((Button) editAction.getOwner()) .setEnabled(Datasource.State.VALID.equals(state) && ds.getItem() != null); } @Override public void collectionChanged(CollectionDatasource ds, Operation operation) { refresh(); } }); docsTable.getDatasource().addListener(new CollectionDsListenerAdapter() { public void collectionChanged(CollectionDatasource ds, CollectionDatasourceListener.Operation operation) { loadCardInfoList(); } }); docsTable.addAction(new AbstractAction("createDoc") { public void actionPerform(Component component) { Doc docPattern = (Doc) getDsContext().get("docsDs").getItem(); if (docPattern != null) { LoadContext loadContext = new LoadContext(docPattern.getClass()); loadContext.setId(docPattern.getId()); loadContext.setView("copy"); docPattern = ServiceLocator.getDataService().load(loadContext); Doc doc; try { doc = docPattern.getClass().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } doc.copyFrom(docPattern); NumerationService ns = ServiceLocator.lookup(NumerationService.NAME); if (StringUtils.isBlank(docPattern.getNumber()) && doc.getDocKind() != null && NumeratorType.ON_CREATE.equals(doc.getDocKind().getNumeratorType())) { String num = ns.getNextNumber(doc); if (num != null) doc.setNumber(num); } doc.setCreateDate(TimeProvider.currentTimestamp()); doc.setTemplate(false); doc.setCreator(UserSessionClient.getUserSession().getUser()); doc.setSubstitutedCreator(UserSessionClient.getUserSession().getCurrentOrSubstitutedUser()); Map<String, Object> params = new HashMap<String, Object>(); params.put("justCreated", true); params.put("initialTemplate", docPattern); Window editor = openEditor(entityName + ".edit", doc, WindowManager.OpenType.THIS_TAB, params); editor.addListener(new CloseListener() { public void windowClosed(String actionId) { // refresh browser regardless of actionId as the new document // could be saved by DocCreator refresh(); } }); } else { showNotification(getMessage("selectDocPattern.msg"), IFrame.NotificationType.HUMANIZED); } } @Override public String getCaption() { return getMessage("actions.createDoc"); } @Override public boolean isVisible() { return super.isVisible() && isTemplate; } }); /* if (createButton != null) { // ? ? // . ?? ? ? //? ? createButton.setEnabled(UserSessionProvider.getUserSession().isEntityOpPermitted(docsDs.getMetaClass(), EntityOp.CREATE)); // ?? " " createButton.addAction(new CreateAction(docsTable) { // ? ? @Override public String getCaption() { final String messagesPackage = getMessagesPack(); return MessageProvider.getMessage(messagesPackage, "actions.CreateNew"); } }); // ?? " ?? " //createButton.addAction(new CopyAction()); } */ // ? ? ?? ? //? ? initTableColoring(); docsDs.addListener(new DsListenerAdapter() { @Override public void stateChanged(Datasource ds, Datasource.State prevState, Datasource.State state) { super.stateChanged(ds, prevState, state); if (Datasource.State.VALID.equals(state)) { loadCardInfoList(); } refresh(); } }); printButton = getComponent("printButton"); if (printButton != null) { printButton.addAction(new ActionPrint("Protocol")); printButton.addAction(new ActionPrint("Resolution_inspector")); printButton.addAction(new ActionPrint("Resolution_justice")); } final Card exclItem = (Card) params.get("exclItem"); if (exclItem != null) { this.setLookupValidator(new Window.Lookup.Validator() { public boolean validate() { Card selectedCard = docsTable.getSingleSelected(); CardService cardService = ServiceLocator.lookup(CardService.NAME); if (selectedCard != null && cardService.isDescendant(exclItem, selectedCard, MetadataProvider.getViewRepository().getView(Card.class, "_minimal"), "parentCard")) { showNotification(MessageProvider.getMessage(CauseGIBDDBrowser.class, "cardIsChild"), IFrame.NotificationType.WARNING); return false; } return true; } }); } addCommentColumn(); addHasAttachmentColumn(); refresh(); }
From source file:com.haulmont.cuba.gui.components.filter.condition.AbstractCondition.java
protected void resolveParam(Element element) { Scripting scripting = AppBeans.get(Scripting.NAME); String aclass = element.attributeValue("class"); if (!isBlank(aclass)) { javaClass = scripting.loadClass(aclass); }//from ww w.j a v a2 s .co m String operatorName = element.attributeValue("operatorType", null); if (operatorName != null) { operator = Op.valueOf(operatorName); } List<Element> paramElements = Dom4j.elements(element, "param"); if (!paramElements.isEmpty()) { Element paramElem = paramElements.iterator().next(); if (BooleanUtils.toBoolean(paramElem.attributeValue("hidden", "false"), "true", "false")) { paramElem = paramElements.iterator().next(); } paramName = paramElem.attributeValue("name"); if (!isBlank(paramElem.attributeValue("javaClass"))) { paramClass = scripting.loadClass(paramElem.attributeValue("javaClass")); } ConditionParamBuilder paramBuilder = AppBeans.get(ConditionParamBuilder.class); if (Strings.isNullOrEmpty(paramName)) { paramName = paramBuilder.createParamName(this); } param = paramBuilder.createParam(this); param.setDateInterval( BooleanUtils.toBoolean(paramElem.attributeValue("isDateInterval", "false"), "true", "false")); param.parseValue(paramElem.getText()); param.setDefaultValue(param.getValue()); } if ("EMPTY".equals(operatorName)) { //for backward compatibility with old filters that still use EMPTY operator operatorName = "NOT_EMPTY"; if (BooleanUtils.isTrue((Boolean) param.getValue())) param.setValue(false); param.setDefaultValue(false); operator = Op.valueOf(operatorName); } }