Search in sources :

Example 1 with DefaultAttribute

use of org.commongeoregistry.adapter.constants.DefaultAttribute in project geoprism-registry by terraframe.

the class VertexServerGeoObject method getValue.

@Override
public Object getValue(String attributeName, Date date) {
    if (attributeName.equals(DefaultAttribute.CODE.getName())) {
        return this.getCode();
    } else if (attributeName.equals(DefaultAttribute.UID.getName())) {
        return this.getUid();
    } else if (attributeName.equals(DefaultAttribute.DISPLAY_LABEL.getName())) {
        return this.getDisplayLabel(date);
    } else if (attributeName.equals(DefaultAttribute.CREATE_DATE.getName())) {
        return this.getCreateDate();
    } else if (attributeName.equals(DefaultAttribute.EXISTS.getName())) {
        return this.getExists(date);
    }
    DefaultAttribute defaultAttr = DefaultAttribute.getByAttributeName(attributeName);
    if (defaultAttr != null && !defaultAttr.isChangeOverTime()) {
        return this.vertex.getObjectValue(attributeName);
    }
    MdAttributeConcreteDAOIF mdAttribute = this.vertex.getMdAttributeDAO(attributeName);
    Object value = this.vertex.getObjectValue(attributeName, date);
    if (value != null && mdAttribute instanceof MdAttributeTermDAOIF) {
        return Classifier.get((String) value);
    }
    return value;
}
Also used : MdAttributeTermDAOIF(com.runwaysdk.dataaccess.MdAttributeTermDAOIF) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) AbstractServerGeoObject(net.geoprism.registry.model.AbstractServerGeoObject) GraphObject(com.runwaysdk.business.graph.GraphObject) DefaultAttribute(org.commongeoregistry.adapter.constants.DefaultAttribute) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Example 2 with DefaultAttribute

use of org.commongeoregistry.adapter.constants.DefaultAttribute in project geoprism-registry by terraframe.

the class VertexServerGeoObject method getValue.

@Override
public Object getValue(String attributeName) {
    if (attributeName.equals(DefaultAttribute.CODE.getName())) {
        return this.getCode();
    } else if (attributeName.equals(DefaultAttribute.UID.getName())) {
        return this.getUid();
    } else if (attributeName.equals(DefaultAttribute.DISPLAY_LABEL.getName())) {
        return this.getDisplayLabel();
    } else if (attributeName.equals(DefaultAttribute.CREATE_DATE.getName())) {
        return this.getCreateDate();
    } else if (attributeName.equals(DefaultAttribute.EXISTS.getName())) {
        return this.getExists();
    }
    DefaultAttribute defaultAttr = DefaultAttribute.getByAttributeName(attributeName);
    if (defaultAttr != null && !defaultAttr.isChangeOverTime()) {
        return this.vertex.getObjectValue(attributeName);
    }
    MdAttributeConcreteDAOIF mdAttribute = this.vertex.getMdAttributeDAO(attributeName);
    Object value = this.getMostRecentValue(attributeName);
    if (value != null && mdAttribute instanceof MdAttributeTermDAOIF) {
        return Classifier.get((String) value);
    }
    return value;
}
Also used : MdAttributeTermDAOIF(com.runwaysdk.dataaccess.MdAttributeTermDAOIF) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) AbstractServerGeoObject(net.geoprism.registry.model.AbstractServerGeoObject) GraphObject(com.runwaysdk.business.graph.GraphObject) DefaultAttribute(org.commongeoregistry.adapter.constants.DefaultAttribute) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Example 3 with DefaultAttribute

use of org.commongeoregistry.adapter.constants.DefaultAttribute in project geoprism-registry by terraframe.

the class AttributeTypeConverter method build.

public AttributeType build(MdAttributeConcreteDAOIF mdAttribute) {
    Locale locale = Session.getCurrentLocale();
    String attributeName = mdAttribute.definesAttribute();
    LocalizedValue displayLabel = AttributeTypeConverter.convert(mdAttribute.getDisplayLabel(locale), mdAttribute.getDisplayLabels());
    LocalizedValue description = AttributeTypeConverter.convert(mdAttribute.getDescription(locale), mdAttribute.getDescriptions());
    boolean required = mdAttribute.isRequired();
    boolean unique = mdAttribute.isUnique();
    boolean isChangeOverTime = true;
    DefaultAttribute defaultAttr = DefaultAttribute.getByAttributeName(attributeName);
    if (defaultAttr != null) {
        isChangeOverTime = defaultAttr.isChangeOverTime();
    }
    if (mdAttribute instanceof MdAttributeBooleanDAOIF) {
        return AttributeType.factory(attributeName, displayLabel, description, AttributeBooleanType.TYPE, required, unique, isChangeOverTime);
    } else if (mdAttribute instanceof MdAttributeLocalDAOIF) {
        return AttributeType.factory(attributeName, displayLabel, description, AttributeLocalType.TYPE, required, unique, isChangeOverTime);
    } else if (mdAttribute instanceof MdAttributeCharacterDAOIF) {
        return AttributeType.factory(attributeName, displayLabel, description, AttributeCharacterType.TYPE, required, unique, isChangeOverTime);
    } else if (mdAttribute instanceof MdAttributeDateDAOIF || mdAttribute instanceof MdAttributeDateTimeDAOIF) {
        return AttributeType.factory(attributeName, displayLabel, description, AttributeDateType.TYPE, required, unique, isChangeOverTime);
    } else if (mdAttribute instanceof MdAttributeDecDAOIF) {
        MdAttributeDecDAOIF mdAttributeDec = (MdAttributeDecDAOIF) mdAttribute;
        AttributeFloatType attributeType = (AttributeFloatType) AttributeType.factory(attributeName, displayLabel, description, AttributeFloatType.TYPE, required, unique, isChangeOverTime);
        attributeType.setPrecision(Integer.parseInt(mdAttributeDec.getLength()));
        attributeType.setScale(Integer.parseInt(mdAttributeDec.getDecimal()));
        return attributeType;
    } else if (mdAttribute instanceof MdAttributeIntegerDAOIF || mdAttribute instanceof MdAttributeLongDAOIF) {
        return AttributeType.factory(attributeName, displayLabel, description, AttributeIntegerType.TYPE, required, unique, isChangeOverTime);
    } else if (mdAttribute instanceof MdAttributeClassificationDAOIF) {
        MdClassificationDAOIF mdClassification = ((MdAttributeClassificationDAOIF) mdAttribute).getMdClassificationDAOIF();
        AttributeClassificationType attributeType = (AttributeClassificationType) AttributeType.factory(attributeName, displayLabel, description, AttributeClassificationType.TYPE, required, unique, isChangeOverTime);
        attributeType.setClassificationType(mdClassification.getValue(MdClassificationInfo.TYPE_NAME));
        String rootOid = ((MdAttributeClassificationDAOIF) mdAttribute).getValue(MdAttributeClassificationInfo.ROOT);
        if (rootOid != null && rootOid.length() > 0) {
            ClassificationType type = new ClassificationType(mdClassification);
            Classification classification = Classification.getByOid(type, rootOid);
            attributeType.setRootTerm(classification.toTerm());
        }
        return attributeType;
    } else if (mdAttribute instanceof MdAttributeEnumerationDAOIF || mdAttribute instanceof MdAttributeTermDAOIF) {
        AttributeTermType attributeType = (AttributeTermType) AttributeType.factory(attributeName, displayLabel, description, AttributeTermType.TYPE, required, unique, isChangeOverTime);
        if (mdAttribute instanceof MdAttributeTermDAOIF) {
            List<RelationshipDAOIF> rels = ((MdAttributeTermDAOIF) mdAttribute).getAllAttributeRoots();
            if (rels.size() > 0) {
                RelationshipDAOIF rel = rels.get(0);
                BusinessDAO classy = (BusinessDAO) rel.getChild();
                TermConverter termBuilder = new TermConverter(classy.getKey());
                Term adapterTerm = termBuilder.build();
                attributeType.setRootTerm(adapterTerm);
            } else {
                throw new ProgrammingErrorException("Expected an attribute root on MdAttribute [" + mdAttribute.getKey() + "].");
            }
        } else {
            throw new ProgrammingErrorException("Enum attributes are not supported at this time.");
        }
        return attributeType;
    }
    throw new UnsupportedOperationException("Unsupported attribute type [" + mdAttribute.getClass().getSimpleName() + "]");
}
Also used : Locale(java.util.Locale) AttributeFloatType(org.commongeoregistry.adapter.metadata.AttributeFloatType) MdClassificationDAOIF(com.runwaysdk.dataaccess.MdClassificationDAOIF) RelationshipDAOIF(com.runwaysdk.dataaccess.RelationshipDAOIF) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) MdAttributeEnumerationDAOIF(com.runwaysdk.dataaccess.MdAttributeEnumerationDAOIF) MdAttributeLongDAOIF(com.runwaysdk.dataaccess.MdAttributeLongDAOIF) MdAttributeIntegerDAOIF(com.runwaysdk.dataaccess.MdAttributeIntegerDAOIF) Classification(net.geoprism.registry.model.Classification) MdAttributeTermDAOIF(com.runwaysdk.dataaccess.MdAttributeTermDAOIF) List(java.util.List) MdAttributeBooleanDAOIF(com.runwaysdk.dataaccess.MdAttributeBooleanDAOIF) BusinessDAO(com.runwaysdk.dataaccess.BusinessDAO) MdAttributeDateTimeDAOIF(com.runwaysdk.dataaccess.MdAttributeDateTimeDAOIF) Term(org.commongeoregistry.adapter.Term) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) ClassificationType(net.geoprism.registry.model.ClassificationType) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) MdAttributeLocalDAOIF(com.runwaysdk.dataaccess.MdAttributeLocalDAOIF) MdAttributeDecDAOIF(com.runwaysdk.dataaccess.MdAttributeDecDAOIF) DefaultAttribute(org.commongeoregistry.adapter.constants.DefaultAttribute) MdAttributeClassificationDAOIF(com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF) MdAttributeDateDAOIF(com.runwaysdk.dataaccess.MdAttributeDateDAOIF) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) MdAttributeCharacterDAOIF(com.runwaysdk.dataaccess.MdAttributeCharacterDAOIF)

Aggregations

MdAttributeTermDAOIF (com.runwaysdk.dataaccess.MdAttributeTermDAOIF)3 DefaultAttribute (org.commongeoregistry.adapter.constants.DefaultAttribute)3 EdgeObject (com.runwaysdk.business.graph.EdgeObject)2 GraphObject (com.runwaysdk.business.graph.GraphObject)2 VertexObject (com.runwaysdk.business.graph.VertexObject)2 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)2 AbstractServerGeoObject (net.geoprism.registry.model.AbstractServerGeoObject)2 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)2 BusinessDAO (com.runwaysdk.dataaccess.BusinessDAO)1 MdAttributeBooleanDAOIF (com.runwaysdk.dataaccess.MdAttributeBooleanDAOIF)1 MdAttributeCharacterDAOIF (com.runwaysdk.dataaccess.MdAttributeCharacterDAOIF)1 MdAttributeClassificationDAOIF (com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF)1 MdAttributeDateDAOIF (com.runwaysdk.dataaccess.MdAttributeDateDAOIF)1 MdAttributeDateTimeDAOIF (com.runwaysdk.dataaccess.MdAttributeDateTimeDAOIF)1 MdAttributeDecDAOIF (com.runwaysdk.dataaccess.MdAttributeDecDAOIF)1 MdAttributeEnumerationDAOIF (com.runwaysdk.dataaccess.MdAttributeEnumerationDAOIF)1 MdAttributeIntegerDAOIF (com.runwaysdk.dataaccess.MdAttributeIntegerDAOIF)1 MdAttributeLocalDAOIF (com.runwaysdk.dataaccess.MdAttributeLocalDAOIF)1 MdAttributeLongDAOIF (com.runwaysdk.dataaccess.MdAttributeLongDAOIF)1 MdClassificationDAOIF (com.runwaysdk.dataaccess.MdClassificationDAOIF)1