use of com.runwaysdk.localization.LocalizedValueStore in project geoprism-registry by terraframe.
the class ChangeRequest method getGeoObjectDisplayLabel.
public LocalizedValue getGeoObjectDisplayLabel() {
if (this.getChangeRequestType().equals(ChangeRequestType.CreateGeoObject)) {
try {
GeoObjectOverTime goTime = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), ((CreateGeoObjectAction) this.getAllAction().next()).getGeoObjectJson());
// Quick little hack to localize a value when it's not in a database or part of a Runway object.
LocalizedValueStore lvs = new LocalizedValueStore();
lvs.getStoreValue().setLocaleMap(goTime.getDisplayLabel(new Date()).getLocaleMap());
return LocalizedValueConverter.convertNoAutoCoalesce(lvs.getStoreValue());
} catch (Exception e) {
logger.error("Error occurred while getting localized label from GeoObject with code [" + this.getGeoObjectCode() + "].", e);
}
} else {
ServerGeoObjectIF serverGO = new ServerGeoObjectService().getGeoObjectByCode(this.getGeoObjectCode(), this.getGeoObjectTypeCode(), false);
if (serverGO != null) {
return serverGO.getDisplayLabel();
}
}
LocalizedValue lv = new LocalizedValue(this.getGeoObjectCode());
lv.setValue(LocalizedValue.DEFAULT_LOCALE, this.getGeoObjectCode());
return lv;
}
use of com.runwaysdk.localization.LocalizedValueStore in project geoprism-registry by terraframe.
the class Task method createNewTask.
public static Task createNewTask(Collection<Roles> roles, TaskTypeIF taskType, Map<String, LocalizedValue> values, String sourceOid) {
LocalizedValueStore lvsTitle = LocalizedValueStore.getByKey(taskType.getTitleKey());
LocalizedValueStore lvsTemplate = LocalizedValueStore.getByKey(taskType.getTemplateKey());
Task task = new Task();
task.setTitle(lvsTitle);
task.setTemplate(lvsTemplate);
task.setSourceOid(sourceOid);
processLocale(lvsTemplate, values, task, MdAttributeLocalInfo.DEFAULT_LOCALE);
Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
for (Locale locale : locales) {
processLocale(lvsTemplate, values, task, locale.toString());
}
task.apply();
for (Roles role : roles) {
TaskHasRole hasRole = new TaskHasRole(task, role);
hasRole.apply();
}
return task;
}
use of com.runwaysdk.localization.LocalizedValueStore in project geoprism-registry by terraframe.
the class TaskTest method deleteAllTasksInTrans.
@Transaction
private static void deleteAllTasksInTrans() {
LocalizedValueStoreQuery lvsq = new LocalizedValueStoreQuery(new QueryFactory());
lvsq.WHERE(lvsq.getStoreKey().EQ(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTemplateKey()).OR(lvsq.getStoreKey().EQ(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTitleKey())));
OIterator<? extends LocalizedValueStore> lvsit = lvsq.getIterator();
while (lvsit.hasNext()) {
LocalizedValueStore template = lvsit.next();
TaskQuery tq = new TaskQuery(new QueryFactory());
tq.WHERE(tq.getTemplate().EQ(template));
tq.OR(tq.getTitle().EQ(template));
OIterator<? extends Task> it2 = tq.getIterator();
while (it2.hasNext()) {
it2.next().delete();
}
template.delete();
}
}
use of com.runwaysdk.localization.LocalizedValueStore in project geoprism-registry by terraframe.
the class LocalizationService method editLocaleInTransaction.
@Transaction
private LocaleView editLocaleInTransaction(LocaleView view) {
if (view.isDefaultLocale) {
LocalizedValueStore lvs = LocalizedValueStore.getByKey(DefaultLocaleView.LABEL);
lvs.lock();
lvs.getStoreValue().setLocaleMap(view.getLabel().getLocaleMap());
lvs.apply();
view.getLabel().setValue(lvs.getStoreValue().getValue());
return view;
} else {
SupportedLocaleIF supportedLocale = (SupportedLocale) com.runwaysdk.localization.LocalizationFacade.getSupportedLocale(view.getLocale());
supportedLocale.appLock();
view.populate(supportedLocale);
supportedLocale.apply();
// Refresh the users session
((Session) Session.getCurrentSession()).reloadPermissions();
// Refresh the entire metadata cache
ServiceFactory.getRegistryService().refreshMetadataCache();
return LocaleView.fromSupportedLocale(supportedLocale);
}
}
use of com.runwaysdk.localization.LocalizedValueStore in project geoprism-registry by terraframe.
the class TaskTest method createInstanceData.
@Request(RequestType.SESSION)
private static void createInstanceData(String sessionId) {
final List<Roles> roles = new ArrayList<Roles>();
roles.add(Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE));
LocalizedValueStore lv = new LocalizedValueStore();
lv.setStoreKey(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTitleKey());
lv.setStoreTag("UIText");
lv.setStructValue(LocalizedValueStore.STOREVALUE, MdAttributeLocalInfo.DEFAULT_LOCALE, "Split Has Orphaned Children");
lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CHINESE.toString(), "斯普利特有孤儿");
lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.KOREAN.toString(), "스 플리트는 고아를 낳았다");
lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CANADA.toString(), "Oh no! Split Has Orphaned Children eh.");
lv.apply();
LocalizedValueStore lv2 = new LocalizedValueStore();
lv2.setStoreKey(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTemplateKey());
lv2.setStoreTag("UIText");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, MdAttributeLocalInfo.DEFAULT_LOCALE, "The {typeName} {oldParentName} has split. You must reassign the children with new parents.");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CHINESE.toString(), "{typeName} {oldParentName}已拆分。 您必须将孩子重新分配给新父母。");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.KOREAN.toString(), "{typeName} {oldParentName}이 (가) 분할되었습니다. 새 부모에게 자녀를 재 할당해야합니다.");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CANADA.toString(), "Oh no! The {typeName} {oldParentName} has split. You must reassign the children with new parents eh.");
lv2.apply();
Map<String, LocalizedValue> values = new HashMap<String, LocalizedValue>();
LocalizedValue lvTypeName = new LocalizedValue(null);
lvTypeName.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, "district");
lvTypeName.setValue(Locale.CHINESE, "区");
lvTypeName.setValue(Locale.KOREAN, "지구");
lvTypeName.setValue(Locale.CANADA, "district eh");
values.put("typeName", lvTypeName);
LocalizedValue lvOldParentName = new LocalizedValue(null);
lvOldParentName.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, "D1");
lvOldParentName.setValue(Locale.CHINESE, "D1 Chinese");
lvOldParentName.setValue(Locale.KOREAN, "D1 Korean");
lvOldParentName.setValue(Locale.CANADA, "D1 Canada");
values.put("oldParentName", lvOldParentName);
Task.createNewTask(roles, TestTaskType.TestGeoObjectSplitOrphanedChildren, values, null);
}
Aggregations