Search in sources :

Example 1 with LocalizedValueStore

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;
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) LocalizedValueStore(com.runwaysdk.localization.LocalizedValueStore) Date(java.util.Date)

Example 2 with LocalizedValueStore

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;
}
Also used : Locale(java.util.Locale) Roles(com.runwaysdk.system.Roles) LocalizedValueStore(com.runwaysdk.localization.LocalizedValueStore)

Example 3 with LocalizedValueStore

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();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LocalizedValueStore(com.runwaysdk.localization.LocalizedValueStore) LocalizedValueStoreQuery(com.runwaysdk.localization.LocalizedValueStoreQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 4 with LocalizedValueStore

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);
    }
}
Also used : SupportedLocale(com.runwaysdk.system.metadata.SupportedLocale) LocalizedValueStore(com.runwaysdk.localization.LocalizedValueStore) SupportedLocaleIF(com.runwaysdk.localization.SupportedLocaleIF) Session(com.runwaysdk.session.Session) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 5 with LocalizedValueStore

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);
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Roles(com.runwaysdk.system.Roles) LocalizedValueStore(com.runwaysdk.localization.LocalizedValueStore) Request(com.runwaysdk.session.Request)

Aggregations

LocalizedValueStore (com.runwaysdk.localization.LocalizedValueStore)5 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 Roles (com.runwaysdk.system.Roles)2 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)2 LocalizedValueStoreQuery (com.runwaysdk.localization.LocalizedValueStoreQuery)1 SupportedLocaleIF (com.runwaysdk.localization.SupportedLocaleIF)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 Request (com.runwaysdk.session.Request)1 Session (com.runwaysdk.session.Session)1 SupportedLocale (com.runwaysdk.system.metadata.SupportedLocale)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)1