use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class GeoObjectImportConfiguration method longitude.
public static AttributeFloatType longitude() {
LocalizedValue label = new LocalizedValue(LocalizationFacade.localize(LONGITUDE_KEY));
LocalizedValue description = new LocalizedValue("");
return new AttributeFloatType(GeoObjectImportConfiguration.LONGITUDE, label, description, false, false, false);
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class LocalizedValueFunction method getValue.
@Override
public Object getValue(FeatureRow feature) {
Map<String, String> localeValues = new HashMap<>();
Set<Entry<String, ShapefileFunction>> entries = map.entrySet();
for (Entry<String, ShapefileFunction> entry : entries) {
String locale = entry.getKey();
ShapefileFunction function = entry.getValue();
Object value = function.getValue(feature);
if (value != null) {
localeValues.put(locale, value.toString());
}
}
return new LocalizedValue("", localeValues);
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class Classification method populate.
public void populate(JsonObject object) {
this.setCode(object.get(AbstractClassification.CODE).getAsString());
LocalizedValue displayLabel = LocalizedValue.fromJSON(object.get(AbstractClassification.DISPLAYLABEL).getAsJsonObject());
this.setDisplayLabel(displayLabel);
LocalizedValue description = LocalizedValue.fromJSON(object.get(AbstractClassification.DESCRIPTION).getAsJsonObject());
this.setDescription(description);
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class ServerGeoObjectType method createMdAttributeFromAttributeType.
public static MdAttributeConcrete createMdAttributeFromAttributeType(MdClass mdClass, AttributeType attributeType) {
MdAttributeConcrete mdAttribute = null;
if (attributeType.getType().equals(AttributeCharacterType.TYPE)) {
mdAttribute = new MdAttributeCharacter();
MdAttributeCharacter mdAttributeCharacter = (MdAttributeCharacter) mdAttribute;
mdAttributeCharacter.setDatabaseSize(MdAttributeCharacterInfo.MAX_CHARACTER_SIZE);
} else if (attributeType.getType().equals(AttributeDateType.TYPE)) {
mdAttribute = new MdAttributeDateTime();
} else if (attributeType.getType().equals(AttributeIntegerType.TYPE)) {
mdAttribute = new MdAttributeLong();
} else if (attributeType.getType().equals(AttributeFloatType.TYPE)) {
AttributeFloatType attributeFloatType = (AttributeFloatType) attributeType;
mdAttribute = new MdAttributeDouble();
mdAttribute.setValue(MdAttributeDoubleInfo.LENGTH, Integer.toString(attributeFloatType.getPrecision()));
mdAttribute.setValue(MdAttributeDoubleInfo.DECIMAL, Integer.toString(attributeFloatType.getScale()));
} else if (attributeType.getType().equals(AttributeTermType.TYPE)) {
mdAttribute = new MdAttributeTerm();
MdAttributeTerm mdAttributeTerm = (MdAttributeTerm) mdAttribute;
MdBusiness classifierMdBusiness = MdBusiness.getMdBusiness(Classifier.CLASS);
mdAttributeTerm.setMdBusiness(classifierMdBusiness);
// TODO implement support for multi-term
// mdAttribute = new MdAttributeMultiTerm();
// MdAttributeMultiTerm mdAttributeMultiTerm =
// (MdAttributeMultiTerm)mdAttribute;
//
// MdBusiness classifierMdBusiness =
// MdBusiness.getMdBusiness(Classifier.CLASS);
// mdAttributeMultiTerm.setMdBusiness(classifierMdBusiness);
} else if (attributeType.getType().equals(AttributeClassificationType.TYPE)) {
AttributeClassificationType attributeClassificationType = (AttributeClassificationType) attributeType;
String classificationTypeCode = attributeClassificationType.getClassificationType();
ClassificationType classificationType = ClassificationType.getByCode(classificationTypeCode);
mdAttribute = new MdAttributeClassification();
MdAttributeClassification mdAttributeTerm = (MdAttributeClassification) mdAttribute;
mdAttributeTerm.setReferenceMdClassification(classificationType.getMdClassificationObject());
Term root = attributeClassificationType.getRootTerm();
if (root != null) {
Classification classification = Classification.get(classificationType, root.getCode());
if (classification == null) {
net.geoprism.registry.DataNotFoundException ex = new net.geoprism.registry.DataNotFoundException();
ex.setTypeLabel(classificationType.getDisplayLabel().getValue());
ex.setDataIdentifier(root.getCode());
ex.setAttributeLabel(GeoObjectMetadata.get().getAttributeDisplayLabel(DefaultAttribute.CODE.getName()));
throw ex;
}
mdAttributeTerm.setValue(MdAttributeClassification.ROOT, classification.getOid());
}
} else if (attributeType.getType().equals(AttributeBooleanType.TYPE)) {
mdAttribute = new MdAttributeBoolean();
}
mdAttribute.setAttributeName(attributeType.getName());
mdAttribute.setValue(MdAttributeConcreteInfo.REQUIRED, Boolean.toString(attributeType.isRequired()));
if (attributeType.isUnique()) {
mdAttribute.addIndexType(MdAttributeIndices.UNIQUE_INDEX);
}
LocalizedValueConverter.populate(mdAttribute.getDisplayLabel(), attributeType.getLabel());
LocalizedValueConverter.populate(mdAttribute.getDescription(), attributeType.getDescription());
mdAttribute.setDefiningMdClass(mdClass);
mdAttribute.apply();
if (attributeType.getType().equals(AttributeTermType.TYPE)) {
MdAttributeTerm mdAttributeTerm = (MdAttributeTerm) mdAttribute;
// Build the parent class term root if it does not exist.
Classifier classTerm = TermConverter.buildIfNotExistdMdBusinessClassifier(mdClass);
// Create the root term node for this attribute
Classifier attributeTermRoot = TermConverter.buildIfNotExistAttribute(mdClass, mdAttributeTerm.getAttributeName(), classTerm);
// Make this the root term of the multi-attribute
attributeTermRoot.addClassifierTermAttributeRoots(mdAttributeTerm).apply();
AttributeTermType attributeTermType = (AttributeTermType) attributeType;
LocalizedValue label = LocalizedValueConverter.convert(attributeTermRoot.getDisplayLabel());
org.commongeoregistry.adapter.Term term = new org.commongeoregistry.adapter.Term(attributeTermRoot.getClassifierId(), label, new LocalizedValue(""));
attributeTermType.setRootTerm(term);
}
return mdAttribute;
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class ServerHierarchyType method toHierarchyType.
public HierarchyType toHierarchyType(boolean includePrivateTypes) {
LocalizedValue description = LocalizedValueConverter.convert(this.getDescription());
final HierarchyType hierarchyType = new HierarchyType(this.getCode(), getLabel(), description, this.getOrganizationCode());
hierarchyType.setAbstractDescription(this.hierarchicalRelationship.getAbstractDescription());
hierarchyType.setAcknowledgement(this.hierarchicalRelationship.getAcknowledgement());
hierarchyType.setDisclaimer(this.hierarchicalRelationship.getDisclaimer());
hierarchyType.setContact(this.hierarchicalRelationship.getContact());
hierarchyType.setPhoneNumber(this.hierarchicalRelationship.getPhoneNumber());
hierarchyType.setEmail(this.hierarchicalRelationship.getEmail());
hierarchyType.setProgress(this.hierarchicalRelationship.getProgress());
hierarchyType.setAccessConstraints(this.hierarchicalRelationship.getAccessConstraints());
hierarchyType.setUseConstraints(this.hierarchicalRelationship.getUseConstraints());
this.getRootGeoObjectTypes(includePrivateTypes).forEach(rootType -> hierarchyType.addRootGeoObjects(rootType));
return hierarchyType;
}
Aggregations