Search in sources :

Example 6 with MdAttributeConcrete

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

the class ServerGeoObjectType method createMdAttributeFromAttributeType.

/**
 * Creates an {@link MdAttributeConcrete} for the given {@link MdBusiness}
 * from the given {@link AttributeType}
 *
 * @pre assumes no attribute has been defined on the type with the given name.
 * @param geoObjectType
 *          TODO
 * @param mdBusiness
 *          Type to receive attribute definition
 * @param attributeType
 *          newly defined attribute
 *
 * @return {@link AttributeType}
 */
@Transaction
public MdAttributeConcrete createMdAttributeFromAttributeType(AttributeType attributeType) {
    MdAttributeConcrete mdAttribute = ServerGeoObjectType.createMdAttributeFromAttributeType(this.mdBusiness, attributeType);
    ListType.createMdAttribute(this, attributeType);
    ((MdVertexDAO) this.mdVertex).copyAttribute(MdAttributeDAO.get(mdAttribute.getOid()));
    return mdAttribute;
}
Also used : MdVertexDAO(com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 7 with MdAttributeConcrete

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

the class ServerGeoObjectType method updateMdAttributeFromAttributeType.

/**
 * Creates an {@link MdAttributeConcrete} for the given {@link MdBusiness}
 * from the given {@link AttributeType}
 *
 * @pre assumes no attribute has been defined on the type with the given name.
 *
 * @param mdBusiness
 *          Type to receive attribute definition
 * @param attributeType
 *          newly defined attribute
 *
 * @return {@link AttributeType}
 */
@Transaction
public static MdAttributeConcrete updateMdAttributeFromAttributeType(MdClass mdClass, AttributeType attributeType) {
    MdAttributeConcreteDAOIF mdAttributeConcreteDAOIF = getMdAttribute(mdClass, attributeType.getName());
    if (mdAttributeConcreteDAOIF != null) {
        // Get the type safe version
        MdAttributeConcrete mdAttribute = (MdAttributeConcrete) BusinessFacade.get(mdAttributeConcreteDAOIF);
        mdAttribute.lock();
        try {
            // The name cannot be updated
            // mdAttribute.setAttributeName(attributeType.getName());
            LocalizedValueConverter.populate(mdAttribute.getDisplayLabel(), attributeType.getLabel());
            LocalizedValueConverter.populate(mdAttribute.getDescription(), attributeType.getDescription());
            if (attributeType instanceof AttributeFloatType) {
                // Refresh the terms
                AttributeFloatType attributeFloatType = (AttributeFloatType) attributeType;
                mdAttribute.setValue(MdAttributeDoubleInfo.LENGTH, Integer.toString(attributeFloatType.getPrecision()));
                mdAttribute.setValue(MdAttributeDoubleInfo.DECIMAL, Integer.toString(attributeFloatType.getScale()));
            } else if (attributeType instanceof AttributeClassificationType) {
                MdAttributeClassification mdAttributeTerm = (MdAttributeClassification) mdAttribute;
                AttributeClassificationType attributeClassificationType = (AttributeClassificationType) attributeType;
                String classificationTypeCode = attributeClassificationType.getClassificationType();
                ClassificationType classificationType = ClassificationType.getByCode(classificationTypeCode);
                Term root = attributeClassificationType.getRootTerm();
                if (root != null) {
                    Classification classification = Classification.get(classificationType, root.getCode());
                    mdAttributeTerm.setValue(MdAttributeClassification.ROOT, classification.getOid());
                }
            }
            mdAttribute.apply();
        } finally {
            mdAttribute.unlock();
        }
        if (attributeType instanceof AttributeTermType) {
            // Refresh the terms
            AttributeTermType attributeTermType = (AttributeTermType) attributeType;
            org.commongeoregistry.adapter.Term getRootTerm = attributeTermType.getRootTerm();
            String classifierKey = TermConverter.buildClassifierKeyFromTermCode(getRootTerm.getCode());
            TermConverter termBuilder = new TermConverter(classifierKey);
            attributeTermType.setRootTerm(termBuilder.build());
        }
        return mdAttribute;
    }
    return null;
}
Also used : MdAttributeClassification(com.runwaysdk.system.metadata.MdAttributeClassification) 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) AttributeFloatType(org.commongeoregistry.adapter.metadata.AttributeFloatType) MdAttributeClassification(com.runwaysdk.system.metadata.MdAttributeClassification) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) TermConverter(net.geoprism.registry.conversion.TermConverter) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 8 with MdAttributeConcrete

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

the class ServerGeoObjectType method updateAttributeType.

public AttributeType updateAttributeType(String attributeTypeJSON) {
    JsonObject attrObj = JsonParser.parseString(attributeTypeJSON).getAsJsonObject();
    AttributeType attrType = AttributeType.parse(attrObj);
    MdAttributeConcrete mdAttribute = ServerGeoObjectType.updateMdAttributeFromAttributeType(this.mdBusiness, attrType);
    attrType = new AttributeTypeConverter().build(MdAttributeConcreteDAO.get(mdAttribute.getOid()));
    this.type.addAttribute(attrType);
    // If this did not error out then add to the cache
    this.refreshCache();
    return attrType;
}
Also used : AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) AttributeTypeConverter(net.geoprism.registry.conversion.AttributeTypeConverter) JsonObject(com.google.gson.JsonObject) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete)

Example 9 with MdAttributeConcrete

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

the class ServerGeoObjectType method createAttributeType.

public AttributeType createAttributeType(AttributeType attributeType) {
    MdAttributeConcrete mdAttribute = this.createMdAttributeFromAttributeType(attributeType);
    attributeType = new AttributeTypeConverter().build(MdAttributeConcreteDAO.get(mdAttribute.getOid()));
    this.type.addAttribute(attributeType);
    // If this did not error out then add to the cache
    this.refreshCache();
    // Refresh the users session
    if (Session.getCurrentSession() != null) {
        ((Session) Session.getCurrentSession()).reloadPermissions();
    }
    return attributeType;
}
Also used : AttributeTypeConverter(net.geoprism.registry.conversion.AttributeTypeConverter) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) Session(com.runwaysdk.session.Session)

Example 10 with MdAttributeConcrete

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

the class RegistryService method createTerm.

/**
 * Creates a new {@link Term} object and makes it a child of the term with the
 * given code.
 *
 * @param sessionId
 * @param parentTemCode
 *          The code of the parent [@link Term}.
 * @param termJSON
 *          JSON of the term object.
 *
 * @return Newly created {@link Term} object.
 */
@Request(RequestType.SESSION)
public Term createTerm(String sessionId, String parentTermCode, String termJSON) {
    JsonObject termJSONobj = JsonParser.parseString(termJSON).getAsJsonObject();
    LocalizedValue label = LocalizedValue.fromJSON(termJSONobj.get(Term.JSON_LOCALIZED_LABEL).getAsJsonObject());
    Term term = new Term(termJSONobj.get(Term.JSON_CODE).getAsString(), label, new LocalizedValue(""));
    Classifier classifier = TermConverter.createClassifierFromTerm(parentTermCode, term);
    TermConverter termBuilder = new TermConverter(classifier.getKeyName());
    Term returnTerm = termBuilder.build();
    List<MdAttributeConcrete> mdAttrList = this.findRootClassifier(classifier);
    this.refreshAttributeTermTypeInCache(mdAttrList);
    return returnTerm;
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) JsonObject(com.google.gson.JsonObject) MdAttributeMultiTerm(com.runwaysdk.system.metadata.MdAttributeMultiTerm) MdAttributeTerm(com.runwaysdk.system.metadata.MdAttributeTerm) Term(org.commongeoregistry.adapter.Term) Classifier(net.geoprism.ontology.Classifier) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) TermConverter(net.geoprism.registry.conversion.TermConverter) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Aggregations

MdAttributeConcrete (com.runwaysdk.system.metadata.MdAttributeConcrete)11 MdAttributeTerm (com.runwaysdk.system.metadata.MdAttributeTerm)4 Classifier (net.geoprism.ontology.Classifier)4 Term (org.commongeoregistry.adapter.Term)4 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)4 AttributeFloatType (org.commongeoregistry.adapter.metadata.AttributeFloatType)4 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)4 JsonObject (com.google.gson.JsonObject)3 Request (com.runwaysdk.session.Request)3 MdAttributeBoolean (com.runwaysdk.system.metadata.MdAttributeBoolean)3 MdAttributeCharacter (com.runwaysdk.system.metadata.MdAttributeCharacter)3 MdAttributeDateTime (com.runwaysdk.system.metadata.MdAttributeDateTime)3 MdAttributeDouble (com.runwaysdk.system.metadata.MdAttributeDouble)3 MdAttributeLong (com.runwaysdk.system.metadata.MdAttributeLong)3 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)3 AttributeTypeConverter (net.geoprism.registry.conversion.AttributeTypeConverter)3 TermConverter (net.geoprism.registry.conversion.TermConverter)3 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)3 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)3 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2