use of com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF in project geoprism-registry by terraframe.
the class GeoObjectImporter method setClassificationValue.
protected void setClassificationValue(ServerGeoObjectIF entity, AttributeType attributeType, String attributeName, Object value, Date startDate, Date endDate) {
if (!this.configuration.isExclusion(attributeName, value.toString())) {
try {
ServerGeoObjectType type = this.configuration.getType();
MdBusinessDAOIF mdBusiness = type.getMdBusinessDAO();
MdAttributeClassificationDAOIF mdAttribute = (MdAttributeClassificationDAOIF) mdBusiness.definesAttribute(attributeName);
if (mdAttribute == null && type.getSuperType() != null) {
mdAttribute = (MdAttributeClassificationDAOIF) type.getSuperType().getMdBusinessDAO().definesAttribute(attributeName);
}
VertexObject classifier = AbstractClassification.findMatchingClassification(value.toString().trim(), mdAttribute);
if (classifier == null) {
throw new UnknownTermException(value.toString().trim(), attributeType);
// Term rootClassification = ( (AttributeClassificationType) attributeType ).getRootTerm();
//
// TermReferenceProblem trp = new TermReferenceProblem(value.toString(), rootClassification.getCode(), mdAttribute.getOid(), attributeName, attributeType.getLabel().getValue());
// trp.addAffectedRowNumber(this.progressListener.getWorkProgress() + 1);
// trp.setHistoryId(this.configuration.getHistoryId());
//
// this.progressListener.addReferenceProblem(trp);
} else {
entity.setValue(attributeName, classifier.getOid(), startDate, endDate);
}
} catch (UnknownTermException e) {
TermValueException ex = new TermValueException();
ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
ex.setCode(e.getCode());
throw e;
}
}
}
use of com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF in project geoprism-registry by terraframe.
the class AttributeValueRestriction method subquery.
@Override
public void subquery(StringBuilder statement, Map<String, Object> parameters, String parameterName) {
String columnName = mdAttribute.getColumnName() + "_cot";
statement.append("(" + columnName + " CONTAINS (");
statement.append(":date BETWEEN startDate AND endDate AND ");
if (this.mdAttribute instanceof MdAttributeClassificationDAOIF && operation.equalsIgnoreCase("eq")) {
MdClassificationDAOIF mdClassification = ((MdAttributeClassificationDAOIF) this.mdAttribute).getMdClassificationDAOIF();
MdEdgeDAOIF mdEdge = mdClassification.getReferenceMdEdgeDAO();
statement.append("value IN ( TRAVERSE out(\"" + mdEdge.getDBClassName() + "\") FROM :" + parameterName + ")");
} else {
statement.append("value = :" + parameterName);
}
// Close CONTAINS parentheses
statement.append(")");
// Close CONDITION parentheses
statement.append(")");
parameters.put(parameterName, this.value);
parameters.put("date", this.date);
}
use of com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF 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() + "]");
}
use of com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF in project geoprism-registry by terraframe.
the class BusinessObjectImporter method setClassificationValue.
protected void setClassificationValue(BusinessObject entity, AttributeType attributeType, String attributeName, Object value) {
if (!this.configuration.isExclusion(attributeName, value.toString())) {
try {
BusinessType type = this.configuration.getType();
MdVertexDAOIF mdBusiness = type.getMdVertexDAO();
MdAttributeClassificationDAOIF mdAttribute = (MdAttributeClassificationDAOIF) mdBusiness.definesAttribute(attributeName);
VertexObject classifier = AbstractClassification.findMatchingClassification(value.toString().trim(), mdAttribute);
if (classifier == null) {
throw new UnknownTermException(value.toString().trim(), attributeType);
} else {
entity.setValue(attributeName, classifier.getOid());
}
} catch (UnknownTermException e) {
TermValueException ex = new TermValueException();
ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
ex.setCode(e.getCode());
throw e;
}
}
}
Aggregations