Search in sources :

Example 6 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness in project geoprism-registry by terraframe.

the class ListTypeVersion method record.

public JsonObject record(String uid) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    NumberFormat numberFormat = NumberFormat.getInstance(Session.getCurrentLocale());
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
    List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributes();
    BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
    query.WHERE(query.get(DefaultAttribute.UID.getName()).EQ(uid));
    JsonObject record = new JsonObject();
    record.addProperty("recordType", "LIST");
    record.addProperty("version", this.getOid());
    record.add("typeLabel", LocalizedValueConverter.convert(this.getListType().getDisplayLabel()).toJSON());
    record.add("attributes", this.getAttributesAsJson());
    try (OIterator<Business> iterator = query.getIterator()) {
        if (iterator.hasNext()) {
            Business row = iterator.next();
            JsonObject object = new JsonObject();
            object.addProperty(ORIGINAL_OID, row.getValue(ORIGINAL_OID));
            for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
                if (this.isValid(mdAttribute)) {
                    String attributeName = mdAttribute.definesAttribute();
                    Object value = row.getObjectValue(attributeName);
                    if (value != null) {
                        if (value instanceof Double) {
                            object.addProperty(mdAttribute.definesAttribute(), numberFormat.format((Double) value));
                        } else if (value instanceof Number) {
                            object.addProperty(mdAttribute.definesAttribute(), (Number) value);
                        } else if (value instanceof Boolean) {
                            object.addProperty(mdAttribute.definesAttribute(), (Boolean) value);
                        } else if (value instanceof String) {
                            object.addProperty(mdAttribute.definesAttribute(), (String) value);
                        } else if (value instanceof Character) {
                            object.addProperty(mdAttribute.definesAttribute(), (Character) value);
                        } else if (value instanceof Date) {
                            object.addProperty(mdAttribute.definesAttribute(), format.format((Date) value));
                        }
                    }
                }
            }
            record.add("data", object);
        }
    }
    JsonArray bbox = this.bbox(uid);
    if (bbox == null || bbox.size() == 0) {
        bbox = this.bbox(null);
    }
    record.add("bbox", bbox);
    return record;
}
Also used : BusinessQuery(com.runwaysdk.business.BusinessQuery) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) MdAttributeCharacter(com.runwaysdk.system.metadata.MdAttributeCharacter) JsonObject(com.google.gson.JsonObject) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) MdAttributeDouble(com.runwaysdk.system.metadata.MdAttributeDouble) Date(java.util.Date) JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) ValueObject(com.runwaysdk.dataaccess.ValueObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) MdAttributeBoolean(com.runwaysdk.system.metadata.MdAttributeBoolean) AttributeBoolean(com.runwaysdk.query.AttributeBoolean) SimpleDateFormat(java.text.SimpleDateFormat) NumberFormat(java.text.NumberFormat) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Example 7 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness in project geoprism-registry by terraframe.

the class ListTypeVersion method getTableName.

private String getTableName() {
    int count = 0;
    MdBusiness mdBusiness = this.getListType().getUniversal().getMdBusiness();
    String name = PREFIX + count + mdBusiness.getTableName();
    if (name.length() > 25) {
        name = name.substring(0, 25);
    }
    while (Database.tableExists(name)) {
        count++;
        name = PREFIX + count + mdBusiness.getTableName();
        if (name.length() > 25) {
            name = name.substring(0, 25);
        }
    }
    return name;
}
Also used : MdBusiness(com.runwaysdk.system.metadata.MdBusiness) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Point(com.vividsolutions.jts.geom.Point)

Example 8 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness in project geoprism-registry by terraframe.

the class MasterListVersion method getTableName.

private String getTableName() {
    int count = 0;
    MdBusiness mdBusiness = this.getMasterlist().getUniversal().getMdBusiness();
    String name = PREFIX + count + mdBusiness.getTableName();
    if (name.length() > 29) {
        name = name.substring(0, 29);
    }
    while (Database.tableExists(name)) {
        count++;
        name = PREFIX + count + mdBusiness.getTableName();
    }
    return name;
}
Also used : MdBusiness(com.runwaysdk.system.metadata.MdBusiness) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint)

Example 9 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness in project geoprism-registry by terraframe.

the class HierarchyExporter method getGeoEntityRelationships.

/**
 * Returns a list of {@link MdTermRelationshipDAOIF} that defines relationships between geoentities.
 *
 * @return list of {@link MdTermRelationshipDAOIF} that defines relationships between geoentities.
 */
private static List<MdTermRelationshipDAOIF> getGeoEntityRelationships() {
    List<MdTermRelationshipDAOIF> list = new LinkedList<MdTermRelationshipDAOIF>();
    QueryFactory qf = new QueryFactory();
    // Export the MdTermRelationships that involve universals
    MdBusiness geoEntityMdBusiness = MdBusiness.getMdBusiness(GeoEntity.CLASS);
    BusinessDAOQuery trQ = qf.businessDAOQuery(MdTermRelationship.CLASS);
    trQ.WHERE(trQ.get(MdTermRelationship.PARENTMDBUSINESS).EQ(geoEntityMdBusiness.getOid()).AND(trQ.get(MdTermRelationship.CHILDMDBUSINESS).EQ(geoEntityMdBusiness.getOid())));
    OIterator<? extends BusinessDAOIF> mdtrI = trQ.getIterator();
    try {
        while (mdtrI.hasNext()) {
            MdTermRelationshipDAOIF businessDAOIF = (MdTermRelationshipDAOIF) mdtrI.next();
            list.add(businessDAOIF);
        }
    } finally {
        mdtrI.close();
    }
    return list;
}
Also used : MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) LinkedList(java.util.LinkedList)

Example 10 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness 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)

Aggregations

MdBusiness (com.runwaysdk.system.metadata.MdBusiness)28 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)13 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)13 Locale (java.util.Locale)12 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)12 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)11 Business (com.runwaysdk.business.Business)10 LinkedList (java.util.LinkedList)10 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)10 QueryFactory (com.runwaysdk.query.QueryFactory)9 MdAttributeLineString (com.runwaysdk.system.gis.metadata.MdAttributeLineString)8 MdAttributeMultiLineString (com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString)8 MdAttributeMultiPoint (com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint)8 MdAttributePoint (com.runwaysdk.system.gis.metadata.MdAttributePoint)8 MdAttributeCharacter (com.runwaysdk.system.metadata.MdAttributeCharacter)8 List (java.util.List)8 MdAttributeBoolean (com.runwaysdk.system.metadata.MdAttributeBoolean)7 MdAttributeDouble (com.runwaysdk.system.metadata.MdAttributeDouble)7 MdAttributeLong (com.runwaysdk.system.metadata.MdAttributeLong)7 JsonArray (com.google.gson.JsonArray)6