Search in sources :

Example 21 with LocalizedValue

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);
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeFloatType(org.commongeoregistry.adapter.metadata.AttributeFloatType)

Example 22 with LocalizedValue

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);
}
Also used : Entry(java.util.Map.Entry) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) HashMap(java.util.HashMap) ShapefileFunction(net.geoprism.data.importer.ShapefileFunction)

Example 23 with LocalizedValue

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);
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue)

Example 24 with LocalizedValue

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;
}
Also used : DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) MdAttributeDateTime(com.runwaysdk.system.metadata.MdAttributeDateTime) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Classifier(net.geoprism.ontology.Classifier) AttributeFloatType(org.commongeoregistry.adapter.metadata.AttributeFloatType) MdAttributeTerm(com.runwaysdk.system.metadata.MdAttributeTerm) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) MdAttributeClassification(com.runwaysdk.system.metadata.MdAttributeClassification) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) MdAttributeLong(com.runwaysdk.system.metadata.MdAttributeLong) MdAttributeClassification(com.runwaysdk.system.metadata.MdAttributeClassification) MdAttributeCharacter(com.runwaysdk.system.metadata.MdAttributeCharacter) Term(org.commongeoregistry.adapter.Term) MdAttributeTerm(com.runwaysdk.system.metadata.MdAttributeTerm) Term(org.commongeoregistry.adapter.Term) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) MdAttributeBoolean(com.runwaysdk.system.metadata.MdAttributeBoolean) MdAttributeDouble(com.runwaysdk.system.metadata.MdAttributeDouble) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Example 25 with LocalizedValue

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;
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType)

Aggregations

LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)133 Request (com.runwaysdk.session.Request)54 Test (org.junit.Test)52 JsonObject (com.google.gson.JsonObject)27 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)22 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)16 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)16 Term (org.commongeoregistry.adapter.Term)15 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)15 Date (java.util.Date)13 Locale (java.util.Locale)13 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)13 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)13 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)11 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)11 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)10 JsonArray (com.google.gson.JsonArray)9 Classification (net.geoprism.registry.model.Classification)9 VertexObject (com.runwaysdk.business.graph.VertexObject)7