/** Use attribute labels as column names */ public void writeAttributes(Iterable<Attribute> attributes) throws IOException { List<String> attributeNames = Lists.newArrayList(); List<String> attributeLabels = Lists.newArrayList(); for (Attribute attr : attributes) { attributeNames.add(attr.getName()); if (attr.getLabel() != null) { attributeLabels.add(attr.getLabel()); } else { attributeLabels.add(attr.getName()); } } writeAttributes(attributeNames, attributeLabels); }
/** * A helper function to create a list of queryTerms based on the information from the * targetAttribute as well as user defined searchTerms. If the user defined searchTerms exist, the * targetAttribute information will not be used. * * @return list of queryTerms */ public Set<String> createLexicalSearchQueryTerms( Attribute targetAttribute, Set<String> searchTerms) { Set<String> queryTerms = new HashSet<>(); if (searchTerms != null && !searchTerms.isEmpty()) { queryTerms.addAll(searchTerms); } if (queryTerms.isEmpty()) { if (StringUtils.isNotBlank(targetAttribute.getLabel())) { queryTerms.add(targetAttribute.getLabel()); } if (StringUtils.isNotBlank(targetAttribute.getDescription())) { queryTerms.add(targetAttribute.getDescription()); } } return queryTerms; }
/** * A helper function to create a list of queryTerms based on the information from the targetAttribute as well as * user defined searchTerms. If the user defined searchTerms exist, the targetAttribute information will not be * used. * * @param targetAttribute * @param searchTerms * @return list of queryTerms */ public Set<String> createLexicalSearchQueryTerms(Attribute targetAttribute, Set<String> searchTerms) { Set<String> queryTerms = new HashSet<>(); if (searchTerms != null && !searchTerms.isEmpty()) { queryTerms.addAll(searchTerms); } if (queryTerms.size() == 0) { if (StringUtils.isNotBlank(targetAttribute.getLabel())) { queryTerms.add(targetAttribute.getLabel()); } if (StringUtils.isNotBlank(targetAttribute.getDescription())) { queryTerms.add(targetAttribute.getDescription()); } } return queryTerms; }
private static Map<String, Object> attributeToMap(Attribute attribute) { Map<String, Object> map = new HashMap<>(); map.put(AttributeMetadata.NAME, attribute.getName()); map.put(AttributeMetadata.LABEL, attribute.getLabel()); map.put(AttributeMetadata.DESCRIPTION, attribute.getDescription()); map.put(AttributeMetadata.TYPE, attribute.getDataType().toString()); map.put(AttributeMetadata.IS_NULLABLE, attribute.isNillable()); map.put(AttributeMetadata.IS_UNIQUE, attribute.isUnique()); if (attribute.getRefEntity() != null) { map.put(AttributeMetadata.REF_ENTITY_TYPE, attribute.getRefEntity().getId()); } return map; } }
private static Map<String, Object> attributeToMap(Attribute attribute) { Map<String, Object> map = new HashMap<String, Object>(); map.put(AttributeMetadata.NAME, attribute.getName()); map.put(AttributeMetadata.LABEL, attribute.getLabel()); map.put(AttributeMetadata.DESCRIPTION, attribute.getDescription()); map.put(AttributeMetadata.TYPE, attribute.getDataType().toString()); map.put(AttributeMetadata.IS_NULLABLE, attribute.isNillable()); map.put(AttributeMetadata.IS_UNIQUE, attribute.isUnique()); if (attribute.getRefEntity() != null) { map.put(AttributeMetadata.REF_ENTITY_TYPE, attribute.getRefEntity().getId()); } return map; } }
private ConstraintViolation createConstraintViolation( Entity entity, Attribute attribute, EntityType entityType, String message) { Object value = getDataValuesForType(entity, attribute); String dataValue = value != null ? value.toString() : null; String fullMessage = format( "Invalid [%s] value [%s] for attribute [%s] of entity [%s] with type [%s].", attribute.getDataType().toString().toLowerCase(), dataValue, attribute.getLabel(), entity.getLabelValue(), entityType.getId()); fullMessage += " " + message; return new ConstraintViolation(fullMessage); }
public static AttributeResult create(Attribute attr, String languageCode) { return create( attr.getLabel(languageCode), attr.getDescription(languageCode), attr.getDataType().toString()); } }
private PackageTreeNode createPackageTreeNode(Attribute amd, EntityType emd) { String title = amd.getLabel(); String key = amd.getName(); String tooltip = amd.getDescription(); List<PackageTreeNode> result = new ArrayList<>(); boolean folder; boolean expanded = false; Map<String, Object> data = new HashMap<>(); data.put("type", "attribute"); data.put("href", "/api/v1/" + emd.getId() + "/meta/" + amd.getName()); data.put("tags", tagService.getTagsForAttribute(emd, amd)); if (amd.getDataType() == AttributeType.COMPOUND) { for (Attribute subAmd : amd.getChildren()) { result.add(createPackageTreeNode(subAmd, emd)); } folder = true; } else { folder = false; } return new PackageTreeNode("attribute", title, key, tooltip, folder, expanded, data, result); }
private static ConstraintViolation createConstraintViolation( Entity entity, Attribute attribute, EntityType entityType) { String message = format( "Invalid %s value '%s' for attribute '%s' of entity '%s'.", attribute.getDataType().toString().toLowerCase(), entity.get(attribute.getName()), attribute.getLabel(), entityType.getId()); Range range = attribute.getRange(); if (range != null) { message += format("Value must be between %d and %d", range.getMin(), range.getMax()); } Long maxLength = attribute.getDataType().getMaxLength(); if (maxLength != null) { message += format("Value must be less than or equal to %d characters", maxLength); } return new ConstraintViolation(message); }
this.label = attr.getLabel(getCurrentUserLanguageCode()); } else this.label = null;
@Override public Unit<? extends Quantity> resolveUnit(Attribute attr, EntityType entityType) { Set<String> tokens = tokenize(attr.getLabel(), attr.getDescription());
@Override public Unit<? extends Quantity> resolveUnit(Attribute attr, EntityType entityType) Set<String> tokens = tokenize(attr.getLabel(), attr.getDescription());
attribute.getDescription() == null ? attribute.getLabel() : attribute.getDescription(); Set<String> searchTerms = splitIntoTerms(description);
@Override public Hit<OntologyTerm> findTags(Attribute attribute, List<String> ontologyIds) String description = attribute.getDescription() == null ? attribute.getLabel() : attribute.getDescription(); Set<String> searchTerms = splitIntoTerms(description); Stemmer stemmer = new Stemmer();
EditorAttributeIdentifier toEditorAttributeIdentifier(Attribute attribute) { if (attribute == null) { return null; } return EditorAttributeIdentifier.create( attribute.getIdentifier(), attribute.getLabel(), EditorEntityTypeIdentifier.create( attribute.getEntity().getId(), attribute.getEntity().getLabel())); }
this.label = attr.getLabel(getCurrentUserLanguageCode()); this.description = attr.getDescription(getCurrentUserLanguageCode()); this.enumOptions = attr.getDataType() == AttributeType.ENUM ? attr.getEnumOptions() : null;
boolean auto = attribute.isAuto(); boolean visible = attribute.isVisible(); String label = attribute.getLabel(); ImmutableMap<String, String> i18nLabel = toI18nLabel(attribute); String description = attribute.getDescription();