Search in sources :

Example 1 with ArrayKey

use of org.compiere.util.Util.ArrayKey in project metasfresh-webui-api by metasfresh.

the class ViewsRepository method createFactoriesMap.

private static ImmutableMap<ArrayKey, IViewFactory> createFactoriesMap(final Collection<IViewFactory> viewFactories) {
    final Map<ArrayKey, IViewFactory> factories = new HashMap<>();
    for (final IViewFactory factory : viewFactories) {
        final ViewFactory annotation = factory.getClass().getAnnotation(ViewFactory.class);
        if (annotation == null) {
            // this might be a development bug
            logger.warn("Skip {} because it's not annotated with {}", factory, ViewFactory.class);
            continue;
        }
        final WindowId windowId = WindowId.fromJson(annotation.windowId());
        JSONViewDataType[] viewTypes = annotation.viewTypes();
        if (viewTypes.length == 0) {
            viewTypes = JSONViewDataType.values();
        }
        for (final JSONViewDataType viewType : viewTypes) {
            factories.put(mkFactoryKey(windowId, viewType), factory);
        }
    }
    return ImmutableMap.copyOf(factories);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ArrayKey(org.compiere.util.Util.ArrayKey) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType)

Example 2 with ArrayKey

use of org.compiere.util.Util.ArrayKey in project metasfresh-webui-api by metasfresh.

the class MenuTree method getNewRecordNodeForWindowId.

public Optional<MenuNode> getNewRecordNodeForWindowId(final WindowId windowId) {
    final DocumentId elementId = windowId.toDocumentId();
    final ArrayKey key = mkTypeAndElementIdKey(MenuNodeType.NewRecord, elementId);
    final List<MenuNode> nodes = nodesByTypeAndElementId.get(key);
    if (nodes == null || nodes.isEmpty()) {
        return Optional.empty();
    }
    final MenuNode newRecordNode = nodes.get(0);
    return Optional.of(newRecordNode);
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ArrayKey(org.compiere.util.Util.ArrayKey)

Example 3 with ArrayKey

use of org.compiere.util.Util.ArrayKey in project metasfresh-webui-api by metasfresh.

the class MenuTree method getFirstNodeByElementIdOrNull.

private MenuNode getFirstNodeByElementIdOrNull(final MenuNodeType type, final DocumentId elementId) {
    final ArrayKey key = mkTypeAndElementIdKey(type, elementId);
    final List<MenuNode> nodes = nodesByTypeAndElementId.get(key);
    if (nodes == null || nodes.isEmpty()) {
        return null;
    }
    return nodes.get(0);
}
Also used : ArrayKey(org.compiere.util.Util.ArrayKey)

Aggregations

ArrayKey (org.compiere.util.Util.ArrayKey)3 JSONViewDataType (de.metas.ui.web.view.json.JSONViewDataType)1 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)1 WindowId (de.metas.ui.web.window.datatypes.WindowId)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1