Search in sources :

Example 76 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class RelationshipVisualizationService method tree.

@Request(RequestType.SESSION)
public JsonElement tree(String sessionId, Date date, String relationshipType, String graphTypeCode, String geoObjectCode, String geoObjectTypeCode) {
    final GeoObjectTypePermissionServiceIF typePermissions = ServiceFactory.getGeoObjectTypePermissionService();
    final ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(geoObjectTypeCode).get();
    JsonObject view = new JsonObject();
    JsonArray jaEdges = new JsonArray();
    view.add("edges", jaEdges);
    JsonArray jaVerticies = new JsonArray();
    view.add("verticies", jaVerticies);
    if (typePermissions.canRead(type.getOrganization().getCode(), type, type.getIsPrivate())) {
        VertexServerGeoObject rootGo = (VertexServerGeoObject) ServiceFactory.getGeoObjectService().getGeoObjectByCode(geoObjectCode, type);
        final GraphType graphType = GraphType.getByCode(relationshipType, graphTypeCode);
        jaVerticies.add(serializeVertex(rootGo, (graphType instanceof UndirectedGraphType) ? "PARENT" : "SELECTED"));
        Set<String> setEdges = new HashSet<String>();
        Set<String> setVerticies = new HashSet<String>();
        if (graphType instanceof UndirectedGraphType) {
            // get parent and get children return the same thing for an undirected
            // graph
            fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
        } else if (graphType instanceof DirectedAcyclicGraphType) {
            // Out is children
            fetchParentsData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
            // In is parents
            fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
        } else {
            // Out is children
            fetchParentsData(true, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
            // In is parents
            fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
        }
    }
    return view;
}
Also used : JsonArray(com.google.gson.JsonArray) DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType) GraphType(net.geoprism.registry.model.GraphType) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GeoObjectTypePermissionServiceIF(net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) HashSet(java.util.HashSet) Request(com.runwaysdk.session.Request)

Example 77 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class GeometryTester method getGeometry.

@Request
public static Geometry getGeometry(String input, String geometryType) {
    try {
        String sCoordinates = input;
        if (sCoordinates.endsWith(",")) {
            sCoordinates = sCoordinates.substring(0, sCoordinates.length() - 1);
        }
        // remove newlines and spaces
        sCoordinates = sCoordinates.replace("\n", "").replace("\r", "").replaceAll("\\s+", "");
        JsonArray joCoordinates = JsonParser.parseString(sCoordinates).getAsJsonArray();
        // TODO : Not sure if we want to keep this polygon -> multipolygon conversion code
        if (geometryType.toUpperCase().equals("POLYGON")) {
            geometryType = "MultiPolygon";
            JsonArray joCoordinates2 = new JsonArray();
            joCoordinates2.add(joCoordinates);
            joCoordinates = joCoordinates2;
        }
        JsonObject joGeometry = new JsonObject();
        {
            joGeometry.add("coordinates", joCoordinates);
            joGeometry.addProperty("type", geometryType);
        }
        GeoJSONReader reader = new GeoJSONReader();
        Geometry jtsGeom = reader.read(joGeometry.toString());
        return jtsGeom;
    } catch (Throwable t) {
        InvalidGeometryException geomEx = new InvalidGeometryException(t);
        geomEx.setReason(RunwayException.localizeThrowable(t, Session.getCurrentLocale()));
        throw geomEx;
    }
}
Also used : JsonArray(com.google.gson.JsonArray) Geometry(com.vividsolutions.jts.geom.Geometry) GeoJSONReader(org.wololo.jts2geojson.GeoJSONReader) JsonObject(com.google.gson.JsonObject) InvalidGeometryException(net.geoprism.registry.io.InvalidGeometryException) Request(com.runwaysdk.session.Request)

Example 78 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class SchedulerTestUtils method clearImportData.

@Request
public static void clearImportData() {
    List<JobHistoryRecord> stoppedJobs = SchedulerManager.interruptAllRunningJobs();
    if (stoppedJobs.size() > 0) {
        try {
            // Wait a few seconds for the job to stop
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
    ValidationProblemQuery vpq = new ValidationProblemQuery(new QueryFactory());
    OIterator<? extends ValidationProblem> vpit = vpq.getIterator();
    while (vpit.hasNext()) {
        ValidationProblem.lock(vpit.next().getOid()).delete();
    }
    ImportErrorQuery ieq = new ImportErrorQuery(new QueryFactory());
    OIterator<? extends ImportError> ieit = ieq.getIterator();
    while (ieit.hasNext()) {
        ImportError.lock(ieit.next().getOid()).delete();
    }
    JobHistoryRecordQuery query = new JobHistoryRecordQuery(new QueryFactory());
    OIterator<? extends JobHistoryRecord> jhrs = query.getIterator();
    while (jhrs.hasNext()) {
        JobHistoryRecord jhr = JobHistoryRecord.lock(jhrs.next().getOid());
        jhr.appLock();
        JobHistory hist = jhr.getChild();
        if (hist instanceof ImportHistory) {
            hist = ImportHistory.lock(hist.getOid());
            hist.appLock();
            ExecutableJob job = jhr.getParent();
            job.appLock();
            // If any tests are currently running, they will be errored out as a result of this.
            if (hist.getStatus().get(0).equals(AllJobStatus.RUNNING) || hist.getStatus().get(0).equals(AllJobStatus.NEW) || hist.getStatus().get(0).equals(AllJobStatus.QUEUED)) {
                logger.error("History with oid [" + hist.getOid() + "] currently has status [" + hist.getStatus().get(0).getEnumName() + "] which is concerning because it is about to be deleted. This will probably cause errors in the running job.");
            }
            // hist = ImportHistory.lock(hist.getOid());
            // hist.appLock();
            // hist = ImportHistory.lock(hist.getOid());
            // VaultFile vf = ( (ImportHistory) hist ).getImportFile();
            // hist.setValue(ImportHistory.IMPORTFILE, null);
            // JobHistoryHistoryComment comment = hist.getHistoryComment();
            // hist.setValue(JobHistory.HISTORYCOMMENT, null);
            // JobHistoryHistoryInformation information = hist.getHistoryInformation();
            // hist.setValue(JobHistory.HISTORYINFORMATION, null);
            // hist.apply();
            // vf.delete();
            // comment.delete();
            // information.delete();
            // hist = ImportHistory.lock(hist.getOid());
            // hist.appLock();
            // hist = ImportHistory.lock(hist.getOid());
            // hist.delete();
            // This will also delete the history.
            JobHistoryRecord.lock(jhr.getOid()).delete();
            ExecutableJob.lock(job.getOid()).delete();
        }
    }
    SynonymQuery sq = new SynonymQuery(new QueryFactory());
    sq.WHERE(sq.getDisplayLabel().localize().EQ("00"));
    OIterator<? extends Synonym> it = sq.getIterator();
    while (it.hasNext()) {
        Synonym.lock(it.next().getOid()).delete();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) JobHistory(com.runwaysdk.system.scheduler.JobHistory) SynonymQuery(com.runwaysdk.system.gis.geo.SynonymQuery) JobHistoryRecordQuery(com.runwaysdk.system.scheduler.JobHistoryRecordQuery) ImportErrorQuery(net.geoprism.registry.etl.ImportErrorQuery) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) ImportHistory(net.geoprism.registry.etl.ImportHistory) JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) ValidationProblemQuery(net.geoprism.registry.etl.ValidationProblemQuery) Request(com.runwaysdk.session.Request)

Example 79 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class TestGeoObjectInfo method newGeoObject.

/**
 * Constructs a new GeoObject and populates all attributes from the data
 * contained within this test wrapper.
 */
@Request
public GeoObject newGeoObject(RegistryAdapter adapter) {
    GeoObject geoObj = adapter.newGeoObjectInstance(this.geoObjectType.getCode());
    this.populate(geoObj);
    return geoObj;
}
Also used : GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Request(com.runwaysdk.session.Request)

Example 80 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class TestGeoObjectInfo method apply.

/**
 * Applies the GeoObject which is represented by this test data into the
 * database.
 *
 * @postcondition Subsequent calls to this.getBusiness will return the
 *                business object which stores additional CGR attributes on
 *                this GeoObject
 * @postcondition Subsequent calls to this.getGeoEntity will return the
 *                GeoEntity which backs this GeoObject
 * @postcondition The applied GeoObject's status will be equal to ACTIVE
 */
@Request
public void apply() {
    ServerGeoObjectIF localServerGO = applyInTrans(date);
    this.registryId = localServerGO.getUid();
    this.isNew = false;
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)340 Test (org.junit.Test)145 JsonObject (com.google.gson.JsonObject)85 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)73 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)73 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)53 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)40 JsonArray (com.google.gson.JsonArray)36 Date (java.util.Date)33 ChangeRequest (net.geoprism.registry.action.ChangeRequest)32 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)31 QueryFactory (com.runwaysdk.query.QueryFactory)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)26 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)22 ListType (net.geoprism.registry.ListType)21 SimpleDateFormat (java.text.SimpleDateFormat)19 Classification (net.geoprism.registry.model.Classification)19 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)19 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17