use of com.runwaysdk.dataaccess.BusinessDAO in project geoprism-registry by terraframe.
the class ListTypeVersionRequiredDefaults method dotItInTrans.
@Transaction
private void dotItInTrans() {
BusinessDAOQuery query = new QueryFactory().businessDAOQuery(ListTypeVersion.CLASS);
query.WHERE(query.aBoolean(ListTypeVersion.WORKING).EQ(true));
query.AND(query.aCharacter(ListTypeVersion.LISTVISIBILITY).EQ((String) null).OR(query.aCharacter(ListTypeVersion.GEOSPATIALVISIBILITY).EQ((String) null)));
logger.info("About to patch " + query.getCount() + " ListTypeVersions with default values for visiblity.");
OIterator<BusinessDAOIF> it = query.getIterator();
try {
while (it.hasNext()) {
BusinessDAO version = (BusinessDAO) it.next();
if (version.getValue(ListTypeVersion.LISTVISIBILITY) == null || version.getValue(ListTypeVersion.LISTVISIBILITY).length() == 0) {
version.setValue(ListTypeVersion.LISTVISIBILITY, ListType.PRIVATE);
}
if (version.getValue(ListTypeVersion.GEOSPATIALVISIBILITY) == null || version.getValue(ListTypeVersion.GEOSPATIALVISIBILITY).length() == 0) {
version.setValue(ListTypeVersion.GEOSPATIALVISIBILITY, ListType.PRIVATE);
}
version.apply();
}
} finally {
it.close();
}
}
use of com.runwaysdk.dataaccess.BusinessDAO in project geoprism-registry by terraframe.
the class LocalizeListMetadataFieldsPatch method migrateExistingLists.
private void migrateExistingLists() {
MasterListQuery mlq = new MasterListQuery(new QueryFactory());
logger.info("Migrating metadata for " + mlq.getCount() + " existing lists.");
try (OIterator<? extends MasterList> it = mlq.getIterator()) {
while (it.hasNext()) {
MasterList list = it.next();
BusinessDAO listDAO = (BusinessDAO) BusinessFacade.getEntityDAO(list);
list.getDescriptionLocal().setDefaultValue(listDAO.getValue(LISTABSTRACT));
list.getProcessLocal().setDefaultValue(listDAO.getValue(PROCESS));
list.getProgressLocal().setDefaultValue(listDAO.getValue(PROGRESS));
list.getAccessConstraintsLocal().setDefaultValue(listDAO.getValue(ACCESSCONSTRAINTS));
list.getUseConstraintsLocal().setDefaultValue(listDAO.getValue(USECONSTRAINTS));
list.getAcknowledgementsLocal().setDefaultValue(listDAO.getValue(ACKNOWLEDGEMENTS));
list.getDisclaimerLocal().setDefaultValue(listDAO.getValue(DISCLAIMER));
list.apply();
}
}
}
use of com.runwaysdk.dataaccess.BusinessDAO 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();
}
}
}
use of com.runwaysdk.dataaccess.BusinessDAO in project geoprism-registry by terraframe.
the class PatchTerms method doIt.
@Transaction
private void doIt() {
ClassifierQuery gQuery = new ClassifierQuery(new QueryFactory());
Classifier clazz = this.getByClassifierId("CLASS");
BusinessDAO clazzDAO = BusinessDAO.get(clazz.getOid()).getBusinessDAO();
clazzDAO.setValue(Classifier.CLASSIFIERPACKAGE, RegistryConstants.REGISTRY_PACKAGE);
clazzDAO.setValue(Classifier.KEYNAME, "CLASS");
clazzDAO.apply();
Classifier root = this.getByClassifierId("ROOT");
BusinessDAO rootDAO = BusinessDAO.get(root.getOid()).getBusinessDAO();
rootDAO.setValue(Classifier.CLASSIFIERPACKAGE, "ROOT");
rootDAO.setValue(Classifier.KEYNAME, "ROOT");
rootDAO.apply();
try (OIterator<? extends Classifier> it = gQuery.getIterator()) {
while (it.hasNext()) {
Classifier classifier = it.next();
LinkedList<Term> parents = new LinkedList<>(GeoEntityUtil.getOrderedAncestors(root, classifier, ClassifierIsARelationship.CLASS));
Collections.reverse(parents);
// Root -> Class Root -> Class -> Attribute -> Option
if (parents.size() == 4) {
Iterator<Term> pit = parents.iterator();
// while (pit.hasNext())
// {
// Classifier p = (Classifier) pit.next();
//
// // logger.error("[" + p.getClassifierId() + "]: ");
// System.out.println(" Parent [" + p.getClassifierId() + "]: ");
// }
pit = parents.iterator();
pit.next();
Classifier parent = (Classifier) pit.next();
classifier.appLock();
classifier.setClassifierPackage(parent.getKey());
classifier.setKeyName(Classifier.buildKey(parent.getKey(), classifier.getClassifierId()));
classifier.apply();
} else if (!(classifier.getOid().equals(clazz.getOid()) || classifier.getOid().equals(root.getOid()))) {
classifier.appLock();
classifier.setClassifierPackage(RegistryConstants.REGISTRY_PACKAGE);
classifier.setKeyName(Classifier.buildKey(RegistryConstants.REGISTRY_PACKAGE, classifier.getClassifierId()));
classifier.apply();
}
}
}
}
use of com.runwaysdk.dataaccess.BusinessDAO in project geoprism-registry by terraframe.
the class AttributeTypeConverter method build.
public AttributeType build(MdAttributeConcreteDAOIF mdAttribute) {
Locale locale = Session.getCurrentLocale();
String attributeName = mdAttribute.definesAttribute();
LocalizedValue displayLabel = AttributeTypeConverter.convert(mdAttribute.getDisplayLabel(locale), mdAttribute.getDisplayLabels());
LocalizedValue description = AttributeTypeConverter.convert(mdAttribute.getDescription(locale), mdAttribute.getDescriptions());
boolean required = mdAttribute.isRequired();
boolean unique = mdAttribute.isUnique();
boolean isChangeOverTime = true;
DefaultAttribute defaultAttr = DefaultAttribute.getByAttributeName(attributeName);
if (defaultAttr != null) {
isChangeOverTime = defaultAttr.isChangeOverTime();
}
if (mdAttribute instanceof MdAttributeBooleanDAOIF) {
return AttributeType.factory(attributeName, displayLabel, description, AttributeBooleanType.TYPE, required, unique, isChangeOverTime);
} else if (mdAttribute instanceof MdAttributeLocalDAOIF) {
return AttributeType.factory(attributeName, displayLabel, description, AttributeLocalType.TYPE, required, unique, isChangeOverTime);
} else if (mdAttribute instanceof MdAttributeCharacterDAOIF) {
return AttributeType.factory(attributeName, displayLabel, description, AttributeCharacterType.TYPE, required, unique, isChangeOverTime);
} else if (mdAttribute instanceof MdAttributeDateDAOIF || mdAttribute instanceof MdAttributeDateTimeDAOIF) {
return AttributeType.factory(attributeName, displayLabel, description, AttributeDateType.TYPE, required, unique, isChangeOverTime);
} else if (mdAttribute instanceof MdAttributeDecDAOIF) {
MdAttributeDecDAOIF mdAttributeDec = (MdAttributeDecDAOIF) mdAttribute;
AttributeFloatType attributeType = (AttributeFloatType) AttributeType.factory(attributeName, displayLabel, description, AttributeFloatType.TYPE, required, unique, isChangeOverTime);
attributeType.setPrecision(Integer.parseInt(mdAttributeDec.getLength()));
attributeType.setScale(Integer.parseInt(mdAttributeDec.getDecimal()));
return attributeType;
} else if (mdAttribute instanceof MdAttributeIntegerDAOIF || mdAttribute instanceof MdAttributeLongDAOIF) {
return AttributeType.factory(attributeName, displayLabel, description, AttributeIntegerType.TYPE, required, unique, isChangeOverTime);
} else if (mdAttribute instanceof MdAttributeClassificationDAOIF) {
MdClassificationDAOIF mdClassification = ((MdAttributeClassificationDAOIF) mdAttribute).getMdClassificationDAOIF();
AttributeClassificationType attributeType = (AttributeClassificationType) AttributeType.factory(attributeName, displayLabel, description, AttributeClassificationType.TYPE, required, unique, isChangeOverTime);
attributeType.setClassificationType(mdClassification.getValue(MdClassificationInfo.TYPE_NAME));
String rootOid = ((MdAttributeClassificationDAOIF) mdAttribute).getValue(MdAttributeClassificationInfo.ROOT);
if (rootOid != null && rootOid.length() > 0) {
ClassificationType type = new ClassificationType(mdClassification);
Classification classification = Classification.getByOid(type, rootOid);
attributeType.setRootTerm(classification.toTerm());
}
return attributeType;
} else if (mdAttribute instanceof MdAttributeEnumerationDAOIF || mdAttribute instanceof MdAttributeTermDAOIF) {
AttributeTermType attributeType = (AttributeTermType) AttributeType.factory(attributeName, displayLabel, description, AttributeTermType.TYPE, required, unique, isChangeOverTime);
if (mdAttribute instanceof MdAttributeTermDAOIF) {
List<RelationshipDAOIF> rels = ((MdAttributeTermDAOIF) mdAttribute).getAllAttributeRoots();
if (rels.size() > 0) {
RelationshipDAOIF rel = rels.get(0);
BusinessDAO classy = (BusinessDAO) rel.getChild();
TermConverter termBuilder = new TermConverter(classy.getKey());
Term adapterTerm = termBuilder.build();
attributeType.setRootTerm(adapterTerm);
} else {
throw new ProgrammingErrorException("Expected an attribute root on MdAttribute [" + mdAttribute.getKey() + "].");
}
} else {
throw new ProgrammingErrorException("Enum attributes are not supported at this time.");
}
return attributeType;
}
throw new UnsupportedOperationException("Unsupported attribute type [" + mdAttribute.getClass().getSimpleName() + "]");
}
Aggregations