use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class ChangeRequest method getGeoObjectDisplayLabel.
public LocalizedValue getGeoObjectDisplayLabel() {
if (this.getChangeRequestType().equals(ChangeRequestType.CreateGeoObject)) {
try {
GeoObjectOverTime goTime = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), ((CreateGeoObjectAction) this.getAllAction().next()).getGeoObjectJson());
// Quick little hack to localize a value when it's not in a database or part of a Runway object.
LocalizedValueStore lvs = new LocalizedValueStore();
lvs.getStoreValue().setLocaleMap(goTime.getDisplayLabel(new Date()).getLocaleMap());
return LocalizedValueConverter.convertNoAutoCoalesce(lvs.getStoreValue());
} catch (Exception e) {
logger.error("Error occurred while getting localized label from GeoObject with code [" + this.getGeoObjectCode() + "].", e);
}
} else {
ServerGeoObjectIF serverGO = new ServerGeoObjectService().getGeoObjectByCode(this.getGeoObjectCode(), this.getGeoObjectTypeCode(), false);
if (serverGO != null) {
return serverGO.getDisplayLabel();
}
}
LocalizedValue lv = new LocalizedValue(this.getGeoObjectCode());
lv.setValue(LocalizedValue.DEFAULT_LOCALE, this.getGeoObjectCode());
return lv;
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class CreateGeoObjectAction method getMessage.
@Override
protected String getMessage() {
GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), this.getGeoObjectJson());
GeoObjectType got = go.getType();
String message = LocalizationFacade.getFromBundles("change.request.email.create.object");
message = message.replaceAll("\\{0\\}", go.getCode());
message = message.replaceAll("\\{1\\}", got.getLabel().getValue(Session.getCurrentLocale()));
return message;
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class CreateGeoObjectAction method apply.
@Override
public void apply() {
String sJson = this.getGeoObjectJson();
GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
ServerGeoObjectType type = ServerGeoObjectType.get(geoObject.getType());
geoObjectPermissionService.enforceCanCreateCR(type.getOrganization().getCode(), type);
super.apply();
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class ETLService method submitImportErrorResolutionInTrans.
@Transaction
private void submitImportErrorResolutionInTrans(String sessionId, String json) {
JsonObject config = JsonParser.parseString(json).getAsJsonObject();
ImportHistory hist = ImportHistory.get(config.get("historyId").getAsString());
hist.getConfig().enforceExecutePermissions();
ImportError err = ImportError.get(config.get("importErrorId").getAsString());
String resolution = config.get("resolution").getAsString();
if (resolution.equals(ErrorResolution.APPLY_GEO_OBJECT.name())) {
String parentTreeNode = config.get("parentTreeNode").toString();
String geoObject = config.get("geoObject").toString();
Boolean isNew = config.get("isNew").getAsBoolean();
GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), geoObject);
if (isNew) {
go.setUid(RegistryIdService.getInstance().next());
geoObject = go.toJSON().toString();
new ServerGeoObjectService().createGeoObject(sessionId, parentTreeNode, geoObject, null, null);
} else {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF serverGO = service.apply(go, isNew, false);
final ServerGeoObjectType type = serverGO.getType();
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, parentTreeNode);
serverGO.setParents(ptnOt);
}
err.appLock();
err.setResolution(resolution);
err.apply();
hist.appLock();
hist.setErrorResolvedCount(hist.getErrorResolvedCount() + 1);
hist.setImportedRecords(hist.getImportedRecords() + 1);
hist.apply();
} else if (resolution.equals(ErrorResolution.IGNORE.name())) {
err.appLock();
err.setResolution(resolution);
err.apply();
} else {
throw new UnsupportedOperationException("Invalid import resolution [" + resolution + "].");
}
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class RegistryController method getGeoObjectOverTime.
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_TIME_GET)
public ResponseIF getGeoObjectOverTime(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TIME_GET_PARAM_ID) String id, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TIME_GET_PARAM_TYPE_CODE) String typeCode) throws JSONException {
GeoObjectOverTime geoObject = this.registryService.getGeoObjectOverTime(request.getSessionId(), id, typeCode);
CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
return new RestBodyResponse(geoObject.toJSON(serializer));
}
Aggregations