private static String getNodeStyleFromAttributeDefinition(AttributeDefinition ad) { if (ad.getNamespace().endsWith("virt")) { return "filled,dashed"; } else if (ad.getNamespace().endsWith("def")) { return "filled"; } else { return "filled"; } }
/** * Returns abbreviation in format [Entity]:[V/D/C]:[friendlyName] * [Entity] is something like 'U' for user, 'G-R' for group-resource etc. * * @param ad attribute definition * @return abbreviation in format [Entity]:[V/D/C]:[friendlyName] */ public static String getAttributeDefinitionAbbreviation(AttributeDefinition ad) { String entity = parseEntityAbbreviation(ad); String type; if (ad.getNamespace().endsWith("virt")) { type = "V"; } else if (ad.getNamespace().endsWith("def")) { type = "D"; } else { type = "C"; } String formattedFriendlyName; String[] splitFriendlyName = ad.getFriendlyName().split(":"); formattedFriendlyName = splitFriendlyName[0]; if (splitFriendlyName.length > 1) { formattedFriendlyName += ":*"; } return entity + ":" + type + ":" + formattedFriendlyName; }
public AttributeHolders(AttributeDefinition attribute, SavedBy savedBy) { super(attribute); this.nameForSearch = attribute.getNamespace() + ":" + attribute.getFriendlyName(); this.namespaceForSearch = attribute.getNamespace(); this.friendlyNameForSearch = attribute.getFriendlyName(); this.typeForSearch = attribute.getType(); this.idForSearch = attribute.getId(); this.valueForSearch = null; this.savedBy = savedBy; }
@Override public String serializeToString() { return this.getClass().getSimpleName() + ":[" + "id=<" + getId() + ">" + ", friendlyName=<" + (getFriendlyName() == null ? "\\0" : BeansUtils.createEscaping(getFriendlyName())) + ">" + ", namespace=<" + (getNamespace() == null ? "\\0" : BeansUtils.createEscaping(getNamespace())) + ">" + ", type=<" + (getType() == null ? "\\0" : BeansUtils.createEscaping(getType())) + ">" + ", unique=<" + unique + ">" + ']'; }
/** * Compares this instance to other instance, throws exception if they are different. * Used to check that Attribute has correct AttributeDefinition fields. * * @param a other instance to be checked for equality * @throws ConsistencyErrorException thrown if any of class attributes differ */ public void checkEquality(AttributeDefinition a) throws ConsistencyErrorException { if (!this.getFriendlyName().equals(a.getFriendlyName())) throw new ConsistencyErrorException("attribute friendlyName is altered"); if (!this.getNamespace().equals(a.getNamespace())) throw new ConsistencyErrorException("attribute namespace is altered"); if (!this.getType().equals(a.getType())) throw new ConsistencyErrorException("attribute type is altered"); if (this.isUnique() != a.isUnique()) throw new ConsistencyErrorException("attribute unique flag is altered"); }
/** * Copy constructor. New attribute will be exactly the same as attribute from parameter. * * @param attributeDefinition attribute to copy */ public AttributeDefinition(AttributeDefinition attributeDefinition) { super(attributeDefinition.getId(), attributeDefinition.getCreatedAt(), attributeDefinition.getCreatedBy(), attributeDefinition.getModifiedAt(), attributeDefinition.getModifiedBy(), attributeDefinition.getCreatedByUid(), attributeDefinition.getModifiedByUid()); this.friendlyName = attributeDefinition.getFriendlyName(); this.namespace = attributeDefinition.getNamespace(); this.description = attributeDefinition.getDescription(); this.type = attributeDefinition.getType(); this.displayName = attributeDefinition.getDisplayName(); this.writable = attributeDefinition.getWritable(); this.unique = attributeDefinition.isUnique(); }