Search in sources :

Example 1 with CreateGeoObjectActionBase

use of net.geoprism.registry.action.geoobject.CreateGeoObjectActionBase 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)

Aggregations

Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 Date (java.util.Date)1 AbstractAction (net.geoprism.registry.action.AbstractAction)1 ChangeRequest (net.geoprism.registry.action.ChangeRequest)1 CreateGeoObjectAction (net.geoprism.registry.action.geoobject.CreateGeoObjectAction)1 CreateGeoObjectActionBase (net.geoprism.registry.action.geoobject.CreateGeoObjectActionBase)1 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)1 UpdateAttributeActionBase (net.geoprism.registry.action.geoobject.UpdateAttributeActionBase)1