Search in sources :

Example 61 with Request

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

the class RegistryService method createGeoObjectType.

/**
 * Creates a {@link GeoObjectType} from the given JSON.
 *
 * @param sessionId
 * @param gtJSON
 *          JSON of the {@link GeoObjectType} to be created.
 * @return newly created {@link GeoObjectType}
 */
@Request(RequestType.SESSION)
public GeoObjectType createGeoObjectType(String sessionId, String gtJSON) {
    ServerGeoObjectType type = null;
    type = new ServerGeoObjectTypeConverter().create(gtJSON);
    ((Session) Session.getCurrentSession()).reloadPermissions();
    // If this did not error out then add to the cache
    ServiceFactory.getMetadataCache().addGeoObjectType(type);
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.TYPE_CACHE_CHANGE, null));
    return type.getType();
}
Also used : ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 62 with Request

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

the class RegistryService method updateTerm.

/**
 * Creates a new {@link Term} object and makes it a child of the term with the
 * given code.
 *
 * @param sessionId
 * @param parentTermCode
 *          TODO
 * @param termJSON
 *          JSON of the term object.
 * @return Updated {@link Term} object.
 */
@Request(RequestType.SESSION)
public Term updateTerm(String sessionId, String parentTermCode, String termJSON) {
    JsonObject termJSONobj = JsonParser.parseString(termJSON).getAsJsonObject();
    String termCode = termJSONobj.get(Term.JSON_CODE).getAsString();
    LocalizedValue value = LocalizedValue.fromJSON(termJSONobj.get(Term.JSON_LOCALIZED_LABEL).getAsJsonObject());
    Classifier classifier = TermConverter.updateClassifier(parentTermCode, termCode, value);
    TermConverter termBuilder = new TermConverter(classifier.getKeyName());
    Term returnTerm = termBuilder.build();
    List<MdAttributeConcrete> mdAttrList = this.findRootClassifier(classifier);
    this.refreshAttributeTermTypeInCache(mdAttrList);
    return returnTerm;
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) JsonObject(com.google.gson.JsonObject) Classifier(net.geoprism.ontology.Classifier) MdAttributeMultiTerm(com.runwaysdk.system.metadata.MdAttributeMultiTerm) MdAttributeTerm(com.runwaysdk.system.metadata.MdAttributeTerm) Term(org.commongeoregistry.adapter.Term) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) TermConverter(net.geoprism.registry.conversion.TermConverter) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 63 with Request

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

the class RegistryService method getGeoObjectOverTime.

@Request(RequestType.SESSION)
public GeoObjectOverTime getGeoObjectOverTime(String sessionId, String id, String typeCode) {
    ServerGeoObjectIF object = this.service.getGeoObject(id, typeCode);
    if (object == null) {
        net.geoprism.registry.DataNotFoundException ex = new net.geoprism.registry.DataNotFoundException();
        ex.setTypeLabel(GeoObjectMetadata.get().getClassDisplayLabel());
        ex.setDataIdentifier(id);
        ex.setAttributeLabel(GeoObjectMetadata.get().getAttributeDisplayLabel(DefaultAttribute.UID.getName()));
        throw ex;
    }
    ServiceFactory.getGeoObjectPermissionService().enforceCanRead(object.getType().getOrganization().getCode(), object.getType());
    return object.toGeoObjectOverTime();
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 64 with Request

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

the class RegistryService method updateOrganization.

/**
 * Updates the given {@link OrganizationDTO} represented as JSON.
 *
 * @pre given {@link OrganizationDTO} must already exist.
 *
 * @param sessionId
 * @param json
 *          JSON of the {@link OrganizationDTO} to be updated.
 * @return updated {@link OrganizationDTO}
 */
@Request(RequestType.SESSION)
public OrganizationDTO updateOrganization(String sessionId, String json) {
    OrganizationDTO organizationDTO = OrganizationDTO.fromJSON(json);
    final Organization org = new OrganizationConverter().update(organizationDTO);
    // If this did not error out then add to the cache
    ServiceFactory.getMetadataCache().addOrganization(org);
    return ServiceFactory.getAdapter().getMetadataCache().getOrganization(org.getCode()).get();
}
Also used : Organization(net.geoprism.registry.Organization) OrganizationDTO(org.commongeoregistry.adapter.metadata.OrganizationDTO) OrganizationConverter(net.geoprism.registry.conversion.OrganizationConverter) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 65 with Request

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

the class RegistryService method updateAttributeType.

/**
 * Updates an attribute in the given {@link GeoObjectType}.
 *
 * @pre given {@link GeoObjectType} must already exist.
 *
 * @param sessionId
 * @param geoObjectTypeCode
 *          string of the {@link GeoObjectType} to be updated.
 * @param attributeTypeJSON
 *          AttributeType to be added to the GeoObjectType
 * @return updated {@link AttributeType}
 */
@Request(RequestType.SESSION)
public AttributeType updateAttributeType(String sessionId, String geoObjectTypeCode, String attributeTypeJSON) {
    ServerGeoObjectType got = ServerGeoObjectType.get(geoObjectTypeCode);
    ServiceFactory.getGeoObjectTypePermissionService().enforceCanWrite(got.getOrganization().getCode(), got, got.getIsPrivate());
    AttributeType attrType = got.updateAttributeType(attributeTypeJSON);
    return attrType;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

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