use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class PatchExistsAndInvalid method getUniversals.
// private void patchMasterlistVersions()
// {
// final Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
//
// MasterListVersionQuery query = new MasterListVersionQuery(new QueryFactory());
//
// try (OIterator<? extends MasterListVersion> it = query.getIterator())
// {
// for (MasterListVersion version : it)
// {
// ServerGeoObjectType type = version.getMasterlist().getGeoObjectType();
//
// // Patch metadata
// AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
// MdAttribute existsMdAttr = MasterListVersion.createMdAttributeFromAttributeType(version, type, existsAttr, locales).getPairs().keySet().iterator().next();
//
// AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
// MdAttribute invalidMdAttr = MasterListVersion.createMdAttributeFromAttributeType(version, type, invalidAttr, locales).getPairs().keySet().iterator().next();
//
//
//
// // Patch instance data
// MdBusiness table = version.getMdBusiness();
//
// String statement = "UPDATE " + table.getTableName() + " SET " + existsMdAttr.getColumnName() + " = " +
//
// Database.executeStatement(statement);
// }
// }
// }
// private void patchMasterlistVersions(ServerGeoObjectType type)
// {
// AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
// MasterList.createMdAttribute(type, existsAttr);
//
// AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
// MasterList.createMdAttribute(type, invalidAttr);
// }
public static List<Universal> getUniversals() {
QueryFactory qf = new QueryFactory();
UniversalQuery uq = new UniversalQuery(qf);
@SuppressWarnings("unchecked") List<Universal> unis = (List<Universal>) uq.getIterator().getAll();
Iterator<Universal> it = unis.iterator();
while (it.hasNext()) {
Universal uni = it.next();
if (uni.getKey().equals(Universal.ROOT_KEY)) {
it.remove();
continue;
}
MdGeoVertexDAOIF superType = GeoVertexType.getMdGeoVertex(uni.getUniversalId()).getSuperClass();
if (superType != null && !superType.definesType().equals(GeoVertex.CLASS)) {
it.remove();
continue;
}
}
return unis;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class PatchExistsAndInvalid method enforceInvalidRequired.
private void enforceInvalidRequired() {
List<Universal> unis = PatchExistsAndInvalid.getUniversals();
for (Universal uni : unis) {
ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
MdGraphClassDAOIF mdClass = type.getMdVertex();
logger.info("Setting invalid mdAttr to required for class [" + mdClass.getKey() + "].");
MdAttributeDAO invalidMdAttr = (MdAttributeDAO) mdClass.definesAttribute(DefaultAttribute.INVALID.getName());
invalidMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.TRUE);
invalidMdAttr.apply();
}
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class PatchExistsAndInvalidInstanceData method patchInstanceData.
private void patchInstanceData() {
List<Universal> unis = PatchExistsAndInvalid.getUniversals();
int applied = 0;
for (Universal uni : unis) {
ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
MdGraphClassDAOIF mdClass = type.getMdVertex();
List<VertexServerGeoObject> data = getInstanceData(type, mdClass);
int current = 0;
final int size = data.size();
logger.info("Starting to patch instance data for type [" + mdClass.getDBClassName() + "] with count [" + size + "] ");
for (VertexServerGeoObject go : data) {
ValueOverTime defaultExists = go.buildDefaultExists();
if (defaultExists != null) {
go.setValue(DefaultAttribute.EXISTS.getName(), Boolean.TRUE, defaultExists.getStartDate(), defaultExists.getEndDate());
go.setValue(DefaultAttribute.INVALID.getName(), false);
// This apply method is mega slow due to the SearchService so we're going to just bypass it
// go.apply(false);
go.getVertex().setValue(GeoVertex.LASTUPDATEDATE, new Date());
go.getVertex().apply();
applied++;
}
if (current % 100 == 0) {
logger.info("Finished record " + current + " of " + size);
}
current++;
}
}
logger.info("Applied " + applied + " records across " + unis.size() + " types.");
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class LocalizedValueConverter method populateGeoObjectTypeLabel.
/**
* Populates the {@link GeoObjectType} display label on the given
* {@link RegistryRole} object.
*
* @param registryRole
*/
public static void populateGeoObjectTypeLabel(RegistryRole registryRole) {
String geoObjectTypeCode = registryRole.getGeoObjectTypeCode();
if (geoObjectTypeCode != null && !geoObjectTypeCode.trim().equals("")) {
Universal universal = Universal.getByKey(geoObjectTypeCode);
registryRole.setGeoObjectTypeLabel(LocalizedValueConverter.convert(universal.getDisplayLabel()));
}
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class HierarchyExporter method exportHierarchyInstances.
/**
* Exports all instances of Universals, including Leaf Types. If a
* file of the specified filename already exists then the file is overwritten.
*
* @param fileName
* The name of the xml file to create.
* @param schemaLocation
* The location of the schema
* @param _exportOnlyModifiedAttributes
* True if only modified attributes should be exported, false otherwise.
*/
@Request
public static void exportHierarchyInstances(String fileName, String schemaLocation, boolean _exportOnlyModifiedAttributes) {
ExportMetadata exportMetadata = new ExportMetadata();
QueryFactory qf = new QueryFactory();
List<Universal> universalList = new LinkedList<Universal>();
UniversalQuery uQ = new UniversalQuery(qf);
// All of the leaf node types will be last in the query
uQ.ORDER_BY(uQ.getIsLeafType(), OrderBy.SortOrder.ASC);
OIterator<? extends Universal> i = uQ.getIterator();
try {
while (i.hasNext()) {
universalList.add(i.next());
}
} finally {
i.close();
}
for (Universal universal : universalList) {
exportUniversalInstances(exportMetadata, universal);
}
List<MdTermRelationshipDAOIF> geoEntityRelList = getGeoEntityRelationships();
for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : geoEntityRelList) {
exportMdTermRelInstances(exportMetadata, mdTermRelationshipDAOIF);
}
VersionExporter.export(fileName, schemaLocation, exportMetadata);
}
Aggregations