use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class VertexServerGeoObject method populate.
@SuppressWarnings("unchecked")
@Override
public void populate(GeoObjectOverTime goTime) {
Map<String, AttributeType> attributes = goTime.getType().getAttributeMap();
attributes.forEach((attributeName, attribute) -> {
if (attributeName.equals(DefaultAttribute.INVALID.getName()) || attributeName.equals(DefaultAttribute.CODE.getName()) || attributeName.equals(DefaultAttribute.UID.getName()) || attributeName.equals(GeoVertex.LASTUPDATEDATE) || attributeName.equals(GeoVertex.CREATEDATE)) {
// Ignore the attributes
} else // }
if (attributeName.equals(DefaultAttribute.DISPLAY_LABEL.getName())) {
this.getValuesOverTime(attributeName).clear();
for (ValueOverTimeDTO votDTO : goTime.getAllValues(attributeName)) {
LocalizedValue label = (LocalizedValue) votDTO.getValue();
this.setDisplayLabel(label, votDTO.getStartDate(), votDTO.getEndDate());
}
} else if (this.vertex.hasAttribute(attributeName) && !this.vertex.getMdAttributeDAO(attributeName).isSystem()) {
this.getValuesOverTime(attributeName).clear();
ValueOverTimeCollectionDTO collection = goTime.getAllValues(attributeName);
for (ValueOverTimeDTO votDTO : collection) {
if (attribute instanceof AttributeTermType) {
Iterator<String> it = (Iterator<String>) votDTO.getValue();
if (it.hasNext()) {
String code = it.next();
Term root = ((AttributeTermType) attribute).getRootTerm();
String parent = TermConverter.buildClassifierKeyFromTermCode(root.getCode());
String classifierKey = Classifier.buildKey(parent, code);
Classifier classifier = Classifier.getByKey(classifierKey);
this.vertex.setValue(attributeName, classifier.getOid(), votDTO.getStartDate(), votDTO.getEndDate());
} else {
this.vertex.setValue(attributeName, (String) null, votDTO.getStartDate(), votDTO.getEndDate());
}
} else if (attribute instanceof AttributeClassificationType) {
String value = (String) votDTO.getValue();
if (value != null) {
Classification classification = Classification.get((AttributeClassificationType) attribute, value);
this.vertex.setValue(attributeName, classification.getVertex(), votDTO.getStartDate(), votDTO.getEndDate());
} else {
this.vertex.setValue(attributeName, (String) null, this.date, this.date);
}
} else {
Object value = votDTO.getValue();
if (value != null) {
this.vertex.setValue(attributeName, value, votDTO.getStartDate(), votDTO.getEndDate());
} else {
this.vertex.setValue(attributeName, (String) null, votDTO.getStartDate(), votDTO.getEndDate());
}
}
}
}
});
this.getValuesOverTime(this.getGeometryAttributeName()).clear();
for (ValueOverTimeDTO votDTO : goTime.getAllValues(DefaultAttribute.GEOMETRY.getName())) {
Geometry geom = goTime.getGeometry(votDTO.getStartDate());
this.setGeometry(geom, votDTO.getStartDate(), votDTO.getEndDate());
}
this.setUid(goTime.getUid());
this.setCode(goTime.getCode());
this.setInvalid(goTime.getInvalid());
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class AccountService method addRolesForOrganization.
private void addRolesForOrganization(List<RegistryRole> registryRoleList, Organization organization) {
LocalizedValue orgDisplayLabel = LocalizedValueConverter.convert(organization.getDisplayLabel());
// Add the RA role
Roles adminRole = organization.getRegistryAdminiRole();
RegistryRole adminRegistryRole = new RegistryRoleConverter().build(adminRole);
adminRegistryRole.setOrganizationLabel(orgDisplayLabel);
registryRoleList.add(adminRegistryRole);
Map<String, ServerGeoObjectType> geoObjectTypeInfo = organization.getGeoObjectTypes();
for (String typeCode : geoObjectTypeInfo.keySet()) {
ServerGeoObjectType type = geoObjectTypeInfo.get(typeCode);
// The cannot be assigned directly to the child type.
if (type.getSuperType() == null) {
// Add the RM role
String rmRoleName = RegistryRole.Type.getRM_RoleName(organization.getCode(), typeCode);
Roles rmRole = Roles.findRoleByName(rmRoleName);
RegistryRole rmRegistryRole = new RegistryRoleConverter().build(rmRole);
rmRegistryRole.setOrganizationLabel(orgDisplayLabel);
LocalizedValue label = type.getLabel();
rmRegistryRole.setGeoObjectTypeLabel(label);
registryRoleList.add(rmRegistryRole);
// Add the RC role
String rcRoleName = RegistryRole.Type.getRC_RoleName(organization.getCode(), typeCode);
Roles rcRole = Roles.findRoleByName(rcRoleName);
RegistryRole rcRegistryRole = new RegistryRoleConverter().build(rcRole);
rcRegistryRole.setOrganizationLabel(orgDisplayLabel);
rcRegistryRole.setGeoObjectTypeLabel(label);
registryRoleList.add(rcRegistryRole);
// Add the AC role
String acRoleName = RegistryRole.Type.getAC_RoleName(organization.getCode(), typeCode);
Roles acRole = Roles.findRoleByName(acRoleName);
RegistryRole acRegistryRole = new RegistryRoleConverter().build(acRole);
acRegistryRole.setOrganizationLabel(orgDisplayLabel);
acRegistryRole.setGeoObjectTypeLabel(label);
registryRoleList.add(acRegistryRole);
}
}
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue 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;
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class SynchronizationConfigService method edit.
@Request(RequestType.SESSION)
public JsonObject edit(String sessionId, String oid) {
JsonObject response = new JsonObject();
if (oid != null && oid.length() > 0) {
SynchronizationConfig config = SynchronizationConfig.lock(oid);
response.add("config", config.toJSON());
}
JsonArray orgs = new JsonArray();
List<Organization> organizations = Organization.getUserAdminOrganizations();
for (Organization organization : organizations) {
JsonArray hierarchies = new JsonArray();
List<ServerHierarchyType> sHierachies = ServerHierarchyType.getForOrganization(organization);
for (ServerHierarchyType hierarchy : sHierachies) {
JsonObject object = new JsonObject();
object.addProperty("label", hierarchy.getDisplayLabel().getValue());
object.addProperty("code", hierarchy.getCode());
hierarchies.add(object);
}
JsonArray systems = new JsonArray();
List<ExternalSystem> esystems = ExternalSystem.getForOrganization(organization);
for (ExternalSystem system : esystems) {
if (system.isExportSupported()) {
LocalizedValue label = LocalizedValueConverter.convert(system.getEmbeddedComponent(ExternalSystem.LABEL));
JsonObject object = new JsonObject();
object.addProperty("label", label.getValue());
object.addProperty("oid", system.getOid());
object.addProperty("type", system.getMdClass().getTypeName());
systems.add(object);
}
}
JsonObject object = new JsonObject();
object.addProperty("label", organization.getDisplayLabel().getValue());
object.addProperty("code", organization.getCode());
object.add("hierarchies", hierarchies);
object.add("systems", systems);
orgs.add(object);
}
response.add("orgs", orgs);
return response;
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class GeoObjectAtTimeShapefileExporter method features.
public FeatureCollection<SimpleFeatureType, SimpleFeature> features(SimpleFeatureType featureType) {
final int BLOCK_SIZE = 2000;
List<SimpleFeature> features = new ArrayList<SimpleFeature>();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
VertexServerGeoObject prev = null;
do {
final VertexSelectGeoObjectQuery query = new VertexSelectGeoObjectQuery(type, this.date, prev);
query.setLimit(BLOCK_SIZE);
final List<VertexServerGeoObject> objects = query.getResults();
prev = null;
for (VertexServerGeoObject object : objects) {
if (!object.getInvalid()) {
builder.set(GEOM, object.getGeometry());
this.attributes.forEach(attribute -> {
String name = attribute.getName();
String columnName = this.getColumnName(name);
Object value = attribute.isChangeOverTime() ? object.getValue(name, this.date) : object.getValue(name);
if (attribute instanceof AttributeTermType) {
builder.set(columnName, GeoObjectUtil.convertToTermString((AttributeTermType) attribute, value));
} else if (attribute instanceof AttributeClassificationType) {
builder.set(columnName, GeoObjectUtil.convertToTermString((AttributeClassificationType) attribute, value));
} else if (attribute instanceof AttributeLocalType) {
builder.set(columnName, ((LocalizedValue) value).getValue());
} else {
builder.set(columnName, value);
}
});
AttributeType attribute = this.getType().getAttribute(DefaultAttribute.DISPLAY_LABEL.getName()).get();
LocalizedValue label = object.getDisplayLabel(this.date);
builder.set(this.getColumnName(attribute.getName() + " " + MdAttributeLocalInfo.DEFAULT_LOCALE), label.getValue(LocalizedValue.DEFAULT_LOCALE));
for (Locale locale : locales) {
builder.set(this.getColumnName(attribute.getName() + " " + locale.toString()), label.getValue(locale));
}
SimpleFeature feature = builder.buildFeature(object.getCode());
features.add(feature);
}
prev = object;
Thread.yield();
}
} while (prev != null);
return new ListFeatureCollection(featureType, features);
}
Aggregations