List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:com.evolveum.midpoint.web.component.prism.ContainerWrapperFactory.java
public <C extends Containerable> AbstractAssociationWrapper createAssociationWrapper( PrismObject<ResourceType> resource, ShadowKindType kind, String shadowIntent, PrismContainer<C> association, ContainerStatus objectStatus, ContainerStatus status, ItemPath path) throws SchemaException { if (association == null || association.getDefinition() == null || (!(association.getDefinition().getCompileTimeClass().equals(ShadowAssociationType.class)) && !(association.getDefinition().getCompileTimeClass() .equals(ResourceObjectAssociationType.class)))) { LOGGER.debug("Association for {} is not supported", association.getComplexTypeDefinition().getTypeClass()); return null; }//w w w . j a v a 2 s . co m result = new OperationResult(CREATE_ASSOCIATION_WRAPPER); //we need to switch association wrapper to single value //the transformation will be as following: // we have single value ShadowAssociationType || ResourceObjectAssociationType, and from each shadowAssociationType we will create // property - name of the property will be association type(QName) and the value will be shadowRef PrismContainerDefinition<C> associationDefinition = association.getDefinition().clone(); associationDefinition.setMaxOccurs(1); RefinedResourceSchema refinedResourceSchema = RefinedResourceSchema.getRefinedSchema(resource); RefinedObjectClassDefinition oc = refinedResourceSchema.getRefinedDefinition(kind, shadowIntent); if (oc == null) { LOGGER.debug("Association for {}/{} not supported by resource {}", kind, shadowIntent, resource); return null; } Collection<RefinedAssociationDefinition> refinedAssociationDefinitions = oc.getAssociationDefinitions(); if (CollectionUtils.isEmpty(refinedAssociationDefinitions)) { LOGGER.debug("Association for {}/{} not supported by resource {}", kind, shadowIntent, resource); return null; } PrismContainer associationTransformed = associationDefinition.instantiate(); AbstractAssociationWrapper associationWrapper; if (association.getDefinition().getCompileTimeClass().equals(ShadowAssociationType.class)) { associationWrapper = new ShadowAssociationWrapper(associationTransformed, objectStatus, status, path); } else if (association.getDefinition().getCompileTimeClass().equals(ResourceObjectAssociationType.class)) { associationWrapper = new ResourceAssociationWrapper(associationTransformed, objectStatus, status, path); } else { return null; } ContainerValueWrapper<C> shadowValueWrapper = new ContainerValueWrapper<>(associationWrapper, associationTransformed.createNewValue(), objectStatus, ContainerStatus.ADDING == status ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, path); List<ItemWrapper> associationValuesWrappers = new ArrayList<>(); for (RefinedAssociationDefinition refinedAssocationDefinition : refinedAssociationDefinitions) { PrismReferenceDefinitionImpl shadowRefDef = new PrismReferenceDefinitionImpl( refinedAssocationDefinition.getName(), ObjectReferenceType.COMPLEX_TYPE, modelServiceLocator.getPrismContext()); shadowRefDef.setMaxOccurs(-1); shadowRefDef.setTargetTypeName(ShadowType.COMPLEX_TYPE); PrismReference shadowAss = shadowRefDef.instantiate(); ItemPath itemPath = null; for (PrismContainerValue<C> associationValue : association.getValues()) { if (association.getDefinition().getCompileTimeClass().equals(ShadowAssociationType.class)) { ShadowAssociationType shadowAssociation = (ShadowAssociationType) associationValue .asContainerable(); if (shadowAssociation.getName().equals(refinedAssocationDefinition.getName())) { itemPath = associationValue.getPath(); shadowAss.add(associationValue.findReference(ShadowAssociationType.F_SHADOW_REF).getValue() .clone()); } } else if (association.getDefinition().getCompileTimeClass() .equals(ResourceObjectAssociationType.class)) { //for now Induced entitlements gui should support only targetRef expression value //that is why no need to look for another expression types within association ResourceObjectAssociationType resourceAssociation = (ResourceObjectAssociationType) associationValue .asContainerable(); if (resourceAssociation.getRef() == null || resourceAssociation.getRef().getItemPath() == null) { continue; } if (resourceAssociation.getRef().getItemPath().asSingleName() .equals(refinedAssocationDefinition.getName())) { itemPath = associationValue.getPath(); MappingType outbound = ((ResourceObjectAssociationType) association.getValue() .asContainerable()).getOutbound(); if (outbound == null) { continue; } ExpressionType expression = outbound.getExpression(); if (expression == null) { continue; } ObjectReferenceType shadowRef = ExpressionUtil.getShadowRefValue(expression); if (shadowRef != null) { shadowAss.add(shadowRef.asReferenceValue().clone()); } } } } if (itemPath == null) { itemPath = new ItemPath(ShadowType.F_ASSOCIATION); } ReferenceWrapper associationValueWrapper = new ReferenceWrapper(shadowValueWrapper, shadowAss, isItemReadOnly(association.getDefinition(), shadowValueWrapper), shadowAss.isEmpty() ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, itemPath); String displayName = refinedAssocationDefinition.getDisplayName(); if (displayName == null) { displayName = refinedAssocationDefinition.getName().getLocalPart(); } associationValueWrapper.setDisplayName(displayName); associationValueWrapper.setFilter(WebComponentUtil.createAssociationShadowRefFilter( refinedAssocationDefinition, modelServiceLocator.getPrismContext(), resource.getOid())); for (ValueWrapper valueWrapper : associationValueWrapper.getValues()) { valueWrapper.setEditEnabled(isEmpty(valueWrapper)); } associationValueWrapper.setTargetTypes(Collections.singletonList(ShadowType.COMPLEX_TYPE)); associationValuesWrappers.add(associationValueWrapper); } shadowValueWrapper.setProperties(associationValuesWrappers); associationWrapper.setProperties(Arrays.asList(shadowValueWrapper)); result.computeStatus(); result.recordSuccessIfUnknown(); return associationWrapper; }
From source file:co.runrightfast.vertx.core.verticles.verticleManager.RunRightFastVerticleManager.java
private void handleRunVerticleHealthChecksMessage( @NonNull final Message<RunVerticleHealthChecks.Request> message) { final RunVerticleHealthChecks.Response.Builder response = RunVerticleHealthChecks.Response.newBuilder(); final RunVerticleHealthChecks.Request request = message.body(); if (hasFilters(request)) { deployments.stream().filter(deployment -> { final RunRightFastVerticleId id = deployment.getRunRightFastVerticleId(); if (CollectionUtils.isEmpty(deployment.getHealthChecks())) { return false; }/* w ww .j av a 2 s .c om*/ return request.getGroupsList().stream().filter(group -> group.equals(id.getGroup())).findFirst() .isPresent() || request.getNamesList().stream().filter(name -> name.equals(id.getName())).findFirst() .isPresent() || request.getVerticleIdsList().stream().filter(id::equalsVerticleId).findFirst() .isPresent(); }).map(this::runVerticleHealthChecks).forEach(response::addAllResults); } else { deployments.stream().map(this::runVerticleHealthChecks).forEach(response::addAllResults); } reply(message, response.build()); }
From source file:io.cloudslang.lang.compiler.validator.PreCompileValidatorImpl.java
@Override public List<Map<String, Map<String, String>>> validateSeqActionSteps(Object oSeqActionStepsRawData, List<RuntimeException> errors) { if (oSeqActionStepsRawData == null) { oSeqActionStepsRawData = new ArrayList<>(); errors.add(new RuntimeException( "Error compiling sequential operation: missing '" + SEQ_STEPS_KEY + "' property.")); }//from www.j a va 2s. c o m List<Map<String, Map<String, String>>> stepsRawData; try { //noinspection unchecked stepsRawData = (List<Map<String, Map<String, String>>>) oSeqActionStepsRawData; } catch (ClassCastException ex) { stepsRawData = new ArrayList<>(); errors.add(new RuntimeException("Error compiling sequential operation: syntax is illegal.\n" + "Below '" + SEQ_STEPS_KEY + "' property there should be a list of steps and not a map.")); } if (CollectionUtils.isEmpty(stepsRawData)) { errors.add(new RuntimeException( "Error compiling sequential operation: missing '" + SEQ_STEPS_KEY + "' data.")); } for (Map<String, Map<String, String>> step : stepsRawData) { if (step.size() > 1) { errors.add(new RuntimeException("Error compiling sequential operation: syntax is illegal.\n" + "Found steps with keyword on the same indentation as the step name " + "or there is no space between step name and hyphen.")); } } return stepsRawData; }
From source file:nc.noumea.mairie.appock.entity.Commande.java
/** * @return le pourcentage d'avancement du traitement de la demande par le service achat *//*ww w . j a v a 2 s . c om*/ public int getAvancementTraitementReception() { if (CollectionUtils.isEmpty(listeCommandeService)) { return 0; } double i = 0; for (CommandeService commandeService : listeCommandeService) { if (commandeService.isReceptionne() || commandeService.isValide()) { i++; } } return AppockUtil.arrondiDizaine(i / listeCommandeService.size()); }
From source file:com.evolveum.midpoint.security.api.SecurityUtil.java
public static NonceCredentialsPolicyType getEffectiveNonceCredentialsPolicy(SecurityPolicyType securityPolicy) throws SchemaException { List<NonceCredentialsPolicyType> noncePolicies = getEffectiveNonceCredentialsPolicies(securityPolicy); if (CollectionUtils.isEmpty(noncePolicies)) { return null; }// w ww. ja va2s .co m if (noncePolicies.size() > 1) { throw new SchemaException("More than one nonce policy"); } return noncePolicies.get(0); }
From source file:com.epam.catgenome.manager.protein.ProteinSequenceReconstructionManager.java
/** * Load CDS from gene file in specified interval [startIndex, endIndex]. * * @param geneTrack gene track//from w w w. j a v a2 s . co m * @param chromosome chromosome * @return map of mRNA to list of its CDS * @throws IOException ir error occurred during working with gene file */ @Transactional(propagation = Propagation.REQUIRED) public Map<Gene, List<Gene>> loadCds(final Track<Gene> geneTrack, final Chromosome chromosome, boolean collapsedTrack) throws GeneReadingException { List<Gene> blocks = geneTrack.getBlocks(); //chromosome blocks = blocks.stream() // removed call to Utils.isFullyOnTrack to fix some bugs .filter(block -> !GeneUtils.isChromosome(block) && GeneUtils.belongsToChromosome(block, chromosome)) .collect(Collectors.toList()); if (CollectionUtils.isEmpty(blocks)) { return Collections.emptyMap(); } GeneFile geneFile = geneFileManager.loadGeneFile(geneTrack.getId()); return fillCdsMap(blocks, geneTrack, geneFile, chromosome, collapsedTrack); }
From source file:com.evolveum.midpoint.web.component.assignment.ConstructionAssociationPanel.java
private void initModels() { resourceModel = new LoadableDetachableModel<PrismObject<ResourceType>>() { @Override//from w w w.j av a 2 s . c o m protected PrismObject<ResourceType> load() { ConstructionType construction = getModelObject().getItem().getValue().asContainerable(); ObjectReferenceType resourceRef = construction.getResourceRef(); Task loadResourceTask = getPageBase().createSimpleTask(OPERATION_LOAD_RESOURCE); OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCE); PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(resourceRef, getPageBase(), loadResourceTask, result); result.computeStatusIfUnknown(); if (!result.isAcceptable()) { LOGGER.error("Cannot find resource referenced from construction. {}", construction, result.getMessage()); result.recordPartialError("Could not find resource referenced from construction."); return null; } return resource; } }; refinedAssociationDefinitionsModel = new LoadableDetachableModel<List<RefinedAssociationDefinition>>() { @Override protected List<RefinedAssociationDefinition> load() { List<RefinedAssociationDefinition> associationDefinitions = new ArrayList<>(); ConstructionType construction = getModelObject().getItem().getValue().asContainerable(); ShadowKindType kind = construction.getKind(); String intent = construction.getIntent(); try { PrismObject<ResourceType> resource = resourceModel.getObject(); if (resource == null) { return associationDefinitions; } RefinedResourceSchema refinedResourceSchema = RefinedResourceSchema.getRefinedSchema(resource); RefinedObjectClassDefinition oc = refinedResourceSchema.getRefinedDefinition(kind, intent); if (oc == null) { LOGGER.debug("Association for {}/{} not supported by resource {}", kind, intent, resource); return associationDefinitions; } associationDefinitions.addAll(oc.getAssociationDefinitions()); if (CollectionUtils.isEmpty(associationDefinitions)) { LOGGER.debug("Association for {}/{} not supported by resource {}", kind, intent, resource); return associationDefinitions; } } catch (Exception ex) { LOGGER.error("Association for {}/{} not supported by resource {}", kind, intent, construction.getResourceRef(), ex.getLocalizedMessage()); } return associationDefinitions; } }; }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaGroupTable.java
protected boolean hasGroupDisallowedProperties(Object[] newGroupProperties) { if (newGroupProperties == null) { return false; }//from w w w . j av a2s . c o m if (CollectionUtils.isEmpty(groupDisallowedProperties)) { return false; } for (Object property : newGroupProperties) { if (groupDisallowedProperties.contains(property)) { return true; } } return false; }
From source file:io.kodokojo.service.DefaultProjectManager.java
@Override public void addUsersToProject(ProjectConfiguration projectConfiguration, List<User> usersToAdd) { if (projectConfiguration == null) { throw new IllegalArgumentException("projectConfiguration must be defined."); }/* w ww .j av a2 s.co m*/ if (CollectionUtils.isEmpty(usersToAdd)) { throw new IllegalArgumentException("usersToAdd must be defined."); } projectConfiguration.getStackConfigurations().forEach(stackConfiguration -> { stackConfiguration.getBrickConfigurations().forEach(brickConfiguration -> { BrickConfigurer brickConfigurer = brickConfigurerProvider .provideFromBrick(brickConfiguration.getBrick()); String entrypoint = "http://" + brickUrlFactory.forgeUrl(projectConfiguration, stackConfiguration.getName(), brickConfiguration); BrickConfigurerData brickConfigurerData = new BrickConfigurerData(projectConfiguration.getName(), stackConfiguration.getName(), entrypoint, domain, IteratorUtils.toList(projectConfiguration.getAdmins()), IteratorUtils.toList(projectConfiguration.getUsers())); brickConfigurerData.getContext().putAll(brickConfiguration.getCustomData()); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Try to add users {} on entrypoint {}.", org.apache.commons.lang.StringUtils.join(usersToAdd, ","), entrypoint); } brickConfigurer.addUsers(brickConfigurerData, usersToAdd); } catch (BrickConfigurationException e) { LOGGER.error("An error occure while add users to brick " + brickConfiguration.getName() + "[" + entrypoint + "] on project " + projectConfiguration.getName() + ".", e); } }); }); }
From source file:com.chadekin.jadys.commons.expression.impl.SqlExpressionFactory.java
private static boolean isBlankValue(Object value) { boolean isBlank = value == null || StringUtils.isBlank(value.toString()); if (!isBlank) { boolean isEmptyCollection = value instanceof Collection && CollectionUtils.isEmpty((Collection) value); boolean isEmptyArray = value.getClass().isArray() && Array.getLength(value) == 0; isBlank = isEmptyCollection || isEmptyArray; }/*from www. j av a 2 s . c o m*/ return isBlank; }