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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations