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;
}
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;
}
}
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();
}
}
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;
}
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;
}
Aggregations