use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class GeoRegistryUtil method createHierarchyType.
@Authenticate
public static String createHierarchyType(String htJSON) {
RegistryAdapter adapter = ServiceFactory.getAdapter();
HierarchyType hierarchyType = HierarchyType.fromJSON(htJSON, adapter);
ServiceFactory.getHierarchyPermissionService().enforceCanCreate(hierarchyType.getOrganizationCode());
ServerHierarchyType sType = new ServerHierarchyTypeBuilder().createHierarchyType(hierarchyType);
// The transaction did not error out, so it is safe to put into the cache.
ServiceFactory.getMetadataCache().addHierarchyType(sType);
return hierarchyType.getCode();
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyMetadata method getHierarchyType.
public static ServerHierarchyType getHierarchyType(String key) {
HierarchyMetadata hierarchy = HierarchyMetadata.getByKey(key);
MdTermRelationship mdTermRelationship = hierarchy.getMdTermRelationship();
ServerHierarchyType hierarchyType = ServerHierarchyType.get(mdTermRelationship);
return hierarchyType;
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class ListType method markAsInvalid.
public void markAsInvalid(ServerHierarchyType hierarchyType, ServerGeoObjectType type) {
boolean isValid = true;
JsonArray hierarchies = this.getHierarchiesAsJson();
ServerGeoObjectType masterlistType = this.getGeoObjectType();
for (int i = 0; i < hierarchies.size(); i++) {
JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
String hCode = hierarchy.get("code").getAsString();
Optional<ServerHierarchyType> ht = ServiceFactory.getMetadataCache().getHierachyType(hCode);
if (ht.isPresent()) {
ServerHierarchyType actualHierarchy = masterlistType.findHierarchy(ht.get(), type);
if (hCode.equals(hierarchyType.getCode()) || actualHierarchy.getCode().equals(hierarchyType.getCode())) {
List<String> pCodes = this.getParentCodes(hierarchy);
if (pCodes.contains(type.getCode()) || type.getCode().equals(masterlistType.getCode())) {
isValid = false;
}
}
} else {
isValid = false;
}
}
if (!isValid) {
this.appLock();
this.setValid(false);
this.apply();
}
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class ListTypeVersion method publishRecord.
@Transaction
public void publishRecord(ServerGeoObjectIF object) {
// Only working lists can be updated from changes to the graph objects
if (this.getWorking()) {
object.setDate(this.getForDate());
// Delete tile cache
ListTileCache.deleteTiles(this);
ListType masterlist = this.getListType();
MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
// Add the type ancestor fields
ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
Collection<AttributeType> attributes = type.getAttributeMap().values();
Business business = new Business(mdBusiness.definesType());
this.publish(masterlist, type, object, business, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
}
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class ListTypeVersion method updateRecord.
@Transaction
public void updateRecord(ServerGeoObjectIF object) {
// Only working lists can be updated from changes to the graph objects
if (this.getWorking()) {
object.setDate(this.getForDate());
// Delete tile cache
ListTileCache.deleteTiles(this);
ListType masterlist = this.getListType();
MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
// Add the type ancestor fields
ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
Collection<AttributeType> attributes = type.getAttributeMap().values();
BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
query.WHERE(query.aCharacter(DefaultAttribute.CODE.getName()).EQ(object.getCode()));
List<Business> records = query.getIterator().getAll();
for (Business record : records) {
try {
record.appLock();
this.publish(masterlist, type, object, record, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
} finally {
record.unlock();
}
}
}
}
Aggregations