use of net.geoprism.registry.BusinessType in project geoprism-registry by terraframe.
the class BusinessObjectImporter method setTermValue.
protected void setTermValue(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();
MdAttributeTermDAOIF mdAttribute = (MdAttributeTermDAOIF) mdBusiness.definesAttribute(attributeName);
Classifier classifier = Classifier.findMatchingTerm(value.toString().trim(), mdAttribute);
if (classifier == null) {
Term rootTerm = ((AttributeTermType) attributeType).getRootTerm();
TermReferenceProblem trp = new TermReferenceProblem(value.toString(), rootTerm.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());
}
} catch (UnknownTermException e) {
TermValueException ex = new TermValueException();
ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
ex.setCode(e.getCode());
throw e;
}
}
}
use of net.geoprism.registry.BusinessType in project geoprism-registry by terraframe.
the class BusinessTypeService method edit.
@Request(RequestType.SESSION)
public JsonObject edit(String sessionId, String oid) {
BusinessType type = BusinessType.get(oid);
type.lock();
return type.toJSON(true);
}
use of net.geoprism.registry.BusinessType in project geoprism-registry by terraframe.
the class BusinessTypeService method apply.
/**
* Creates a {@link BusinessType} from the given JSON.
*
* @param sessionId
* @param ptJSON
* JSON of the {@link BusinessType} to be created.
* @return newly created {@link BusinessType}
*/
@Request(RequestType.SESSION)
public JsonObject apply(String sessionId, String ptJSON) {
BusinessType type = BusinessType.apply(JsonParser.parseString(ptJSON).getAsJsonObject());
((Session) Session.getCurrentSession()).reloadPermissions();
return type.toJSON();
}
use of net.geoprism.registry.BusinessType in project geoprism-registry by terraframe.
the class BusinessTypeService method unlock.
@Request(RequestType.SESSION)
public void unlock(String sessionId, String oid) {
BusinessType type = BusinessType.get(oid);
type.unlock();
}
use of net.geoprism.registry.BusinessType in project geoprism-registry by terraframe.
the class BusinessObjectImporterTest method mockImport.
private ImportHistory mockImport(BusinessObjectImportConfiguration config) throws Throwable {
if (config.getDate() == null) {
config.setDate(new Date());
}
config.setImportStrategy(ImportStrategy.NEW_AND_UPDATE);
DataImportJob job = new DataImportJob();
job.apply();
ImportHistory hist = (ImportHistory) job.createNewHistory();
config.setHistoryId(hist.getOid());
config.setJobId(job.getOid());
BusinessType type = config.getType();
hist.appLock();
hist.setImportFileId(config.getVaultFileId());
hist.setConfigJson(config.toJSON().toString());
hist.setOrganization(type.getOrganization());
hist.setGeoObjectTypeCode(type.getCode());
hist.apply();
ExecutionContext context = MockScheduler.executeJob(job, hist);
hist = (ImportHistory) context.getHistory();
return hist;
}
Aggregations