use of net.geoprism.registry.MasterListVersionQuery in project geoprism-registry by terraframe.
the class PatchExistsAndInvalid method patchMasterlistVersions.
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();
// We are accessing it in this weird way because MasterList was changed to have new localized attributes. If we run this patch
// before masterlist is patched then simply instantiating a MasterList object will throw an error when it tries to load the structs.
BusinessDAO versionDAO = (BusinessDAO) BusinessDAO.get(version.getOid());
String masterListOid = versionDAO.getValue(MasterListVersion.MASTERLIST);
BusinessDAO masterListDAO = (BusinessDAO) BusinessDAO.get(masterListOid);
String universalOid = masterListDAO.getValue(MasterList.UNIVERSAL);
ServerGeoObjectType type = ServerGeoObjectType.get(Universal.get(universalOid));
// Patch metadata
// AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
// MasterListVersion.createMdAttributeFromAttributeType(version, type, existsAttr, locales);
AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
MasterListVersion.createMdAttributeFromAttributeType(version, type, invalidAttr, locales);
// Instance data is too hard to patch. We're just going to republish all the lists
logger.info("Master list version [" + version.getKey() + "] has been queued for republishing.");
PublishMasterListVersionJob job = new PublishMasterListVersionJob();
job.setMasterListVersion(version);
job.setMasterListId(masterListOid);
job.apply();
// job.start();
// JobHistory history = job.createNewHistory();
JobHistory history = new JobHistory();
history.setStartTime(new Date());
history.addStatus(AllJobStatus.QUEUED);
history.apply();
JobHistoryRecord record = new JobHistoryRecord(job, history);
record.apply();
}
}
}
Aggregations