Search in sources :

Example 1 with BusinessType

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;
        }
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) TermValueException(net.geoprism.registry.io.TermValueException) BusinessType(net.geoprism.registry.BusinessType) MdAttributeTermDAOIF(com.runwaysdk.dataaccess.MdAttributeTermDAOIF) Classifier(net.geoprism.ontology.Classifier) Term(org.commongeoregistry.adapter.Term) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) TermReferenceProblem(net.geoprism.registry.etl.TermReferenceProblem) UnknownTermException(org.commongeoregistry.adapter.dataaccess.UnknownTermException)

Example 2 with BusinessType

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);
}
Also used : BusinessType(net.geoprism.registry.BusinessType) Request(com.runwaysdk.session.Request)

Example 3 with BusinessType

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();
}
Also used : BusinessType(net.geoprism.registry.BusinessType) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 4 with BusinessType

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();
}
Also used : BusinessType(net.geoprism.registry.BusinessType) Request(com.runwaysdk.session.Request)

Example 5 with BusinessType

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;
}
Also used : ExecutionContext(com.runwaysdk.system.scheduler.ExecutionContext) DataImportJob(net.geoprism.registry.etl.DataImportJob) BusinessType(net.geoprism.registry.BusinessType) Date(java.util.Date) ImportHistory(net.geoprism.registry.etl.ImportHistory)

Aggregations

BusinessType (net.geoprism.registry.BusinessType)17 Request (com.runwaysdk.session.Request)13 JsonObject (com.google.gson.JsonObject)5 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)5 Test (org.junit.Test)5 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)3 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)2 Session (com.runwaysdk.session.Session)2 SimpleDateFormat (java.text.SimpleDateFormat)2 TermValueException (net.geoprism.registry.io.TermValueException)2 UnknownTermException (org.commongeoregistry.adapter.dataaccess.UnknownTermException)2 JSONObject (org.json.JSONObject)2 RunwayException (com.runwaysdk.RunwayException)1 SmartException (com.runwaysdk.business.SmartException)1 VertexObject (com.runwaysdk.business.graph.VertexObject)1 MdAttributeClassificationDAOIF (com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF)1 MdAttributeTermDAOIF (com.runwaysdk.dataaccess.MdAttributeTermDAOIF)1 VaultFile (com.runwaysdk.system.VaultFile)1 ExecutionContext (com.runwaysdk.system.scheduler.ExecutionContext)1