Search in sources :

Example 56 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class SearchService method deleteSearchTable.

@Transaction
public void deleteSearchTable() {
    String suffix = this.getSuffix();
    MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
    mdEdge.getBusinessDAO().delete();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
    mdVertex.getBusinessDAO().delete();
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 57 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class XMLImporter method importXMLDefinitions.

@Transaction
public List<ServerElement> importXMLDefinitions(Organization organization, InputStream istream) {
    TransactionState state = TransactionState.getCurrentTransactionState();
    state.putTransactionObject("transaction-state", this.cache);
    LinkedList<ServerElement> list = new LinkedList<ServerElement>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = factory.newDocumentBuilder();
        Document doc = dBuilder.parse(istream);
        list.addAll(this.createTypes(organization, doc));
        list.addAll(this.createHierarchies(organization, doc));
        list.addAll(this.createDirectedAcyclicGraphTypes(doc));
        list.addAll(this.createUndirectedGraphTypes(doc));
    } catch (ParserConfigurationException | IOException | SAXException e) {
        throw new ProgrammingErrorException(e);
    }
    return list;
}
Also used : TransactionState(com.runwaysdk.dataaccess.transaction.TransactionState) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) ServerElement(net.geoprism.registry.model.ServerElement) LinkedList(java.util.LinkedList) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) SAXException(org.xml.sax.SAXException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 58 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class ChangeRequestServiceTest method createCRTrans.

@Transaction
private String createCRTrans(String actionType) {
    ChangeRequest cr = new ChangeRequest();
    cr.addApprovalStatus(AllGovernanceStatus.PENDING);
    cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
    if (actionType.equals(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME)) {
        cr.setGeoObjectCode(FastTestDataset.PROV_CENTRAL.getCode());
        cr.setGeoObjectTypeCode(FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
    } else {
        cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
        cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
    }
    cr.apply();
    AbstractAction action = null;
    if (actionType.equals(CreateGeoObjectAction.CLASS)) {
        action = new CreateGeoObjectAction();
        action.setApiVersion("1.0");
        ((CreateGeoObjectActionBase) action).setGeoObjectJson(FastTestDataset.CAMBODIA.fetchGeoObjectOverTime().toJSON().toString());
        action.addApprovalStatus(AllGovernanceStatus.PENDING);
        action.setCreateActionDate(new Date());
        action.apply();
    } else if (actionType.equals(UpdateAttributeAction.CLASS)) {
        action = new UpdateAttributeAction();
        action.setApiVersion("1.0");
        ((UpdateAttributeActionBase) action).setAttributeName(FastTestDataset.AT_National_Anthem.getAttributeName());
        ((UpdateAttributeActionBase) action).setJson(UPDATE_ATTR_JSON);
        action.addApprovalStatus(AllGovernanceStatus.PENDING);
        action.setCreateActionDate(new Date());
        action.apply();
    } else if (actionType.equals(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME)) {
        action = new UpdateAttributeAction();
        action.setApiVersion("1.0");
        ((UpdateAttributeActionBase) action).setAttributeName(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME);
        ((UpdateAttributeActionBase) action).setJson(UPDATE_PARENT_ATTR_JSON);
        action.addApprovalStatus(AllGovernanceStatus.PENDING);
        action.setCreateActionDate(new Date());
        action.apply();
    } else {
        throw new UnsupportedOperationException();
    }
    cr.addAction(action).apply();
    return cr.toJSON().toString();
}
Also used : CreateGeoObjectAction(net.geoprism.registry.action.geoobject.CreateGeoObjectAction) CreateGeoObjectActionBase(net.geoprism.registry.action.geoobject.CreateGeoObjectActionBase) UpdateAttributeActionBase(net.geoprism.registry.action.geoobject.UpdateAttributeActionBase) ChangeRequest(net.geoprism.registry.action.ChangeRequest) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 59 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class TaskTest method deleteAllTasksInTrans.

@Transaction
private static void deleteAllTasksInTrans() {
    LocalizedValueStoreQuery lvsq = new LocalizedValueStoreQuery(new QueryFactory());
    lvsq.WHERE(lvsq.getStoreKey().EQ(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTemplateKey()).OR(lvsq.getStoreKey().EQ(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTitleKey())));
    OIterator<? extends LocalizedValueStore> lvsit = lvsq.getIterator();
    while (lvsit.hasNext()) {
        LocalizedValueStore template = lvsit.next();
        TaskQuery tq = new TaskQuery(new QueryFactory());
        tq.WHERE(tq.getTemplate().EQ(template));
        tq.OR(tq.getTitle().EQ(template));
        OIterator<? extends Task> it2 = tq.getIterator();
        while (it2.hasNext()) {
            it2.next().delete();
        }
        template.delete();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LocalizedValueStore(com.runwaysdk.localization.LocalizedValueStore) LocalizedValueStoreQuery(com.runwaysdk.localization.LocalizedValueStoreQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 60 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphType method update.

@Transaction
public void update(JsonObject object) {
    try {
        this.appLock();
        if (object.has(DirectedAcyclicGraphType.DISPLAYLABEL)) {
            LocalizedValue label = LocalizedValue.fromJSON(object.getAsJsonObject(DirectedAcyclicGraphType.DISPLAYLABEL));
            LocalizedValueConverter.populate(this.getDisplayLabel(), label);
        }
        if (object.has(DirectedAcyclicGraphType.DESCRIPTION)) {
            LocalizedValue description = LocalizedValue.fromJSON(object.getAsJsonObject(DirectedAcyclicGraphType.DESCRIPTION));
            LocalizedValueConverter.populate(this.getDescription(), description);
        }
        this.apply();
    } finally {
        this.unlock();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

Transaction (com.runwaysdk.dataaccess.transaction.Transaction)131 QueryFactory (com.runwaysdk.query.QueryFactory)29 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)27 JsonObject (com.google.gson.JsonObject)17 Date (java.util.Date)15 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)15 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)14 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)13 LinkedList (java.util.LinkedList)11 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)11 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)10 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)10 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)10 List (java.util.List)10 ChangeRequest (net.geoprism.registry.action.ChangeRequest)10 VertexObject (com.runwaysdk.business.graph.VertexObject)8 IOException (java.io.IOException)8 GeoObjectImportConfiguration (net.geoprism.registry.io.GeoObjectImportConfiguration)8 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)8 JSONObject (org.json.JSONObject)8