public static boolean hasPrimaryIdentifier(Collection<? extends ResourceAttribute<?>> identifiers, ObjectClassComplexTypeDefinition objectClassDefinition) { for (ResourceAttribute identifier: identifiers) { if (objectClassDefinition.isPrimaryIdentifier(identifier.getElementName())) { return true; } } return false; }
public static ResourceObjectIdentification createFromAttributes(ObjectClassComplexTypeDefinition objectClassDefinition, Collection<? extends ResourceAttribute<?>> attributes) throws SchemaException { Collection<? extends ResourceAttribute<?>> primaryIdentifiers = null; Collection<? extends ResourceAttribute<?>> secondaryIdentifiers = null; for (ResourceAttribute<?> identifier: attributes) { if (objectClassDefinition.isPrimaryIdentifier(identifier.getElementName())) { if (primaryIdentifiers == null) { primaryIdentifiers = new ArrayList<>(); } ((Collection)primaryIdentifiers).add(identifier); } else if (objectClassDefinition.isSecondaryIdentifier(identifier.getElementName())) { if (secondaryIdentifiers == null) { secondaryIdentifiers = new ArrayList<>(); } ((Collection)secondaryIdentifiers).add(identifier); } } return new ResourceObjectIdentification(objectClassDefinition, primaryIdentifiers, secondaryIdentifiers); }
public static ResourceObjectIdentification create(ObjectClassComplexTypeDefinition objectClassDefinition, Collection<? extends ResourceAttribute<?>> allIdentifiers) throws SchemaException { if (allIdentifiers == null) { throw new IllegalArgumentException("Cannot create ResourceObjectIdentification with null identifiers"); } Collection<? extends ResourceAttribute<?>> primaryIdentifiers = null; Collection<? extends ResourceAttribute<?>> secondaryIdentifiers = null; for (ResourceAttribute<?> identifier: allIdentifiers) { if (objectClassDefinition.isPrimaryIdentifier(identifier.getElementName())) { if (primaryIdentifiers == null) { primaryIdentifiers = new ArrayList<>(); } ((Collection)primaryIdentifiers).add(identifier); } else if (objectClassDefinition.isSecondaryIdentifier(identifier.getElementName())) { if (secondaryIdentifiers == null) { secondaryIdentifiers = new ArrayList<>(); } ((Collection)secondaryIdentifiers).add(identifier); } else { throw new SchemaException("Attribute "+identifier+" is neither primary not secondary identifier in object class "+objectClassDefinition); } } return new ResourceObjectIdentification(objectClassDefinition, primaryIdentifiers, secondaryIdentifiers); }
private void processIdentifiers(RefinedAttributeDefinition rAttrDef, ObjectClassComplexTypeDefinition objectClassDef) { QName attrName = rAttrDef.getName(); if (objectClassDef.isPrimaryIdentifier(attrName)) { ((Collection)getPrimaryIdentifiers()).add(rAttrDef); } if (rAttrDef.isSecondaryIdentifierOverride() == null) { if (objectClassDef.isSecondaryIdentifier(attrName)) { ((Collection)getSecondaryIdentifiers()).add(rAttrDef); } } else if (rAttrDef.isSecondaryIdentifierOverride()) { ((Collection)getSecondaryIdentifiers()).add(rAttrDef); } }
String nameValue = null; for (ResourceAttribute<?> attr : identifiers) { if (objectClass.isPrimaryIdentifier(attr.getElementName())) { uidValue = ((ResourceAttribute<String>) attr).getValue().getValue();