use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class RegistryRoleConverter method buildRA_Role.
/**
* Returns the {@link RegistryRole} object for the given RA {@link Roles}.
*
* Precondition: assumes the roleName is a valid RA role
*
* @param role RunwaySDK role
*
* @return {@link RegistryRole}
*/
private RegistryRole buildRA_Role(Roles raRole) {
LocalizedValue localizedValue = LocalizedValueConverter.convert(raRole.getDisplayLabel());
String[] strArray = raRole.getRoleName().split("\\.");
String organizationCode = strArray[2];
return RegistryRole.createRA(localizedValue, organizationCode);
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class CambodiaDemoHierarchyGenerator method generateHierarchyTypes.
private static void generateHierarchyTypes() {
RegistryAdapterServer registry = new RegistryAdapterServer(RegistryIdService.getInstance());
HierarchyType ht = MetadataFactory.newHierarchyType("Cambodia", new LocalizedValue("Cambodia"), new LocalizedValue(""), null, registry);
ServiceFactory.getHierarchyService().createHierarchyType(Session.getCurrentSession().getOid(), ht.toJSON().toString());
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class GeoObjectImporter method getName.
/**
* @param feature
* @return The entityName as defined by the 'name' attribute of the feature
*/
private LocalizedValue getName(FeatureRow row) {
ShapefileFunction function = this.configuration.getFunction(GeoObject.DISPLAY_LABEL);
if (function == null) {
return null;
}
Object attribute = function.getValue(row);
if (attribute != null) {
return (LocalizedValue) attribute;
}
return null;
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class GeoObjectImporter method validateRow.
@Transaction
public void validateRow(FeatureRow row) throws InterruptedException {
try {
// Refresh the session because it might expire on long imports
final long curWorkProgress = this.progressListener.getWorkProgress();
if ((this.lastValidateSessionRefresh + GeoObjectImporter.refreshSessionRecordCount) < curWorkProgress) {
SessionFacade.renewSession(Session.getCurrentSession().getOid());
this.lastValidateSessionRefresh = curWorkProgress;
}
try {
/*
* 1. Check for location problems
*/
if (this.configuration.isPostalCode() && PostalCodeFactory.isAvailable(this.configuration.getType())) {
// Skip location synonym check
} else if (this.configuration.getHierarchy() != null && this.configuration.getLocations().size() > 0) {
this.getParent(row);
}
/*
* 2. Check for serialization and term problems
*/
String code = this.getCode(row);
ServerGeoObjectIF entity;
if (code == null || code.length() <= 0) {
RequiredMappingException ex = new RequiredMappingException();
ex.setAttributeLabel(GeoObjectTypeMetadata.getAttributeDisplayLabel(DefaultAttribute.CODE.getName()));
throw ex;
}
entity = service.newInstance(this.configuration.getType());
entity.setCode(code);
entity.setInvalid(false);
try {
LocalizedValue entityName = this.getName(row);
if (entityName != null && this.hasValue(entityName)) {
entity.setDisplayLabel(entityName, this.configuration.getStartDate(), this.configuration.getEndDate());
}
Geometry geometry = (Geometry) this.getFormatSpecificImporter().getGeometry(row);
if (geometry != null) {
// geometry.getSRID().
if (geometry.isValid()) {
entity.setGeometry(geometry, this.configuration.getStartDate(), this.configuration.getEndDate());
} else {
InvalidGeometryException geomEx = new InvalidGeometryException();
throw geomEx;
}
}
Map<String, AttributeType> attributes = this.configuration.getType().getAttributeMap();
Set<Entry<String, AttributeType>> entries = attributes.entrySet();
for (Entry<String, AttributeType> entry : entries) {
String attributeName = entry.getKey();
if (!attributeName.equals(GeoObject.CODE)) {
ShapefileFunction function = this.configuration.getFunction(attributeName);
if (function != null) {
Object value = function.getValue(row);
if (value != null && !this.isEmptyString(value)) {
AttributeType attributeType = entry.getValue();
this.setValue(entity, attributeType, attributeName, value);
}
}
}
}
GeoObjectOverTime go = entity.toGeoObjectOverTime(false);
go.toJSON().toString();
if (this.configuration.isExternalImport()) {
ShapefileFunction function = this.configuration.getExternalIdFunction();
Object value = function.getValue(row);
if (value == null || !(value instanceof String || value instanceof Integer || value instanceof Long) || (value instanceof String && ((String) value).length() == 0)) {
throw new InvalidExternalIdException();
}
}
} finally {
entity.unlock();
}
} catch (IgnoreRowException e) {
// Do nothing
} catch (Throwable t) {
RowValidationProblem problem = new RowValidationProblem(t);
problem.addAffectedRowNumber(curWorkProgress + 1);
problem.setHistoryId(this.configuration.historyId);
this.progressListener.addRowValidationProblem(problem);
}
this.progressListener.setWorkProgress(curWorkProgress + 1);
if (Thread.interrupted()) {
throw new InterruptedException();
}
Thread.yield();
} catch (Throwable e) {
e.printStackTrace();
}
}
use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.
the class GeoObjectImportConfiguration method latitude.
public static AttributeFloatType latitude() {
LocalizedValue label = new LocalizedValue(LocalizationFacade.localize(LATITUDE_KEY));
LocalizedValue description = new LocalizedValue("");
return new AttributeFloatType(GeoObjectImportConfiguration.LATITUDE, label, description, false, false, false);
}
Aggregations