Search in sources :

Example 1 with TransitionPermissionService

use of net.geoprism.registry.transition.TransitionPermissionService in project geoprism-registry by terraframe.

the class TransitionEvent method toJSON.

public JsonObject toJSON(boolean includeTransitions) {
    DateFormat format = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    LocalizedValue localizedValue = LocalizedValueConverter.convert(this.getEmbeddedComponent(TransitionEvent.DESCRIPTION));
    ServerGeoObjectType beforeType = ServerGeoObjectType.get(this.getBeforeTypeCode());
    ServerGeoObjectType afterType = ServerGeoObjectType.get(this.getAfterTypeCode());
    JsonObject object = new JsonObject();
    object.addProperty(TransitionEvent.OID, this.getOid());
    object.addProperty(TransitionEvent.EVENTID, this.getEventId());
    object.addProperty(TransitionEvent.BEFORETYPECODE, beforeType.getCode());
    object.addProperty(TransitionEvent.AFTERTYPECODE, afterType.getCode());
    object.addProperty(TransitionEvent.EVENTDATE, format.format(this.getEventDate()));
    object.addProperty("beforeTypeLabel", beforeType.getLabel().getValue());
    object.addProperty("afterTypeLabel", afterType.getLabel().getValue());
    object.add(TransitionEvent.DESCRIPTION, localizedValue.toJSON());
    GsonBuilder builder = new GsonBuilder();
    JsonArray ja = builder.create().toJsonTree(new TransitionPermissionService().getPermissions(this)).getAsJsonArray();
    object.add("permissions", ja);
    if (includeTransitions) {
        JsonArray transitions = this.getTransitions().stream().map(e -> e.toJSON()).collect(() -> new JsonArray(), (array, element) -> array.add(element), (listA, listB) -> listA.addAll(listB));
        object.add("transitions", transitions);
    }
    return object;
}
Also used : JsonArray(com.google.gson.JsonArray) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) JsonObject(com.google.gson.JsonObject) StringUtils(org.apache.commons.lang.StringUtils) TransitionImpact(net.geoprism.registry.graph.transition.Transition.TransitionImpact) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonParser(com.google.gson.JsonParser) GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) GsonBuilder(com.google.gson.GsonBuilder) ServiceFactory(net.geoprism.registry.service.ServiceFactory) ArrayList(java.util.ArrayList) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) GeoObjectTypeRestrictionUtil(net.geoprism.registry.query.graph.GeoObjectTypeRestrictionUtil) Map(java.util.Map) ParseException(java.text.ParseException) LinkedList(java.util.LinkedList) TransitionPermissionService(net.geoprism.registry.transition.TransitionPermissionService) JsonSerializable(net.geoprism.registry.view.JsonSerializable) DateFormat(java.text.DateFormat) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Optional(org.commongeoregistry.adapter.Optional) GraphQuery(com.runwaysdk.business.graph.GraphQuery) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) GeoRegistryUtil(net.geoprism.registry.GeoRegistryUtil) TransitionType(net.geoprism.registry.graph.transition.Transition.TransitionType) Collectors(java.util.stream.Collectors) MdVertexDAO(com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO) Page(net.geoprism.registry.view.Page) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) List(java.util.List) JsonArray(com.google.gson.JsonArray) SingleActorDAOIF(com.runwaysdk.business.rbac.SingleActorDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) Session(com.runwaysdk.session.Session) RolePermissionService(net.geoprism.registry.permission.RolePermissionService) TransitionPermissionService(net.geoprism.registry.transition.TransitionPermissionService) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) GsonBuilder(com.google.gson.GsonBuilder) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) JsonObject(com.google.gson.JsonObject) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

GsonBuilder (com.google.gson.GsonBuilder)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 GraphQuery (com.runwaysdk.business.graph.GraphQuery)1 RoleDAOIF (com.runwaysdk.business.rbac.RoleDAOIF)1 SingleActorDAOIF (com.runwaysdk.business.rbac.SingleActorDAOIF)1 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)1 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)1 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 Session (com.runwaysdk.session.Session)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1