Search in sources :

Example 1 with EntityType

use of com.developmentontheedge.be5.metadata.model.EntityType in project be5 by DevelopmentOnTheEdge.

the class MetaImpl method getOrderedEntitiesByModules.

@Override
public Map<String, List<Entity>> getOrderedEntitiesByModules(EntityType entityType, String language) {
    HashMap<String, List<Entity>> result = new HashMap<>();
    for (Module module : getProject().getModulesAndApplication()) {
        List<OrderedEntity> entities = new ArrayList<>();
        for (Entity entity : module.getEntities()) {
            if (entityType == null || entity.getType() == entityType) {
                entities.add(new OrderedEntity(entity, getTitle(entity, language)));
            }
        }
        Collections.sort(entities);
        result.put(module.getName(), entities.stream().map(e -> e.entity).collect(Collectors.toList()));
    }
    return result;
}
Also used : Entity(com.developmentontheedge.be5.metadata.model.Entity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Module(com.developmentontheedge.be5.metadata.model.Module)

Example 2 with EntityType

use of com.developmentontheedge.be5.metadata.model.EntityType in project be5 by DevelopmentOnTheEdge.

the class MetaImpl method getOrderedEntities.

@Override
public List<Entity> getOrderedEntities(EntityType entityType, String language) {
    List<OrderedEntity> entities = new ArrayList<>();
    for (Module module : getProject().getModulesAndApplication()) {
        for (Entity entity : module.getEntities()) {
            if (entityType == null || entity.getType() == entityType) {
                entities.add(new OrderedEntity(entity, getTitle(entity, language)));
            }
        }
    }
    Collections.sort(entities);
    return entities.stream().map(e -> e.entity).collect(Collectors.toList());
}
Also used : Operation(com.developmentontheedge.be5.metadata.model.Operation) Arrays(java.util.Arrays) SqlTypeUtils(com.developmentontheedge.sql.format.SqlTypeUtils) ProjectProvider(com.developmentontheedge.be5.api.services.ProjectProvider) ProjectElementException(com.developmentontheedge.be5.metadata.exception.ProjectElementException) QueryLink(com.developmentontheedge.be5.api.services.QueryLink) Meta(com.developmentontheedge.be5.api.services.Meta) HashMap(java.util.HashMap) RoleType(com.developmentontheedge.be5.metadata.RoleType) Query(com.developmentontheedge.be5.metadata.model.Query) Function(java.util.function.Function) Be5ErrorCode(com.developmentontheedge.be5.api.exceptions.Be5ErrorCode) ArrayList(java.util.ArrayList) BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement) Entity(com.developmentontheedge.be5.metadata.model.Entity) EntityItem(com.developmentontheedge.be5.metadata.model.EntityItem) LocalizationElement(com.developmentontheedge.be5.metadata.model.LocalizationElement) BeModelElementSupport(com.developmentontheedge.be5.metadata.model.base.BeModelElementSupport) Utils(com.developmentontheedge.be5.util.Utils) Locale(java.util.Locale) Map(java.util.Map) EntityLocalizations(com.developmentontheedge.be5.metadata.model.EntityLocalizations) StreamSupport(java.util.stream.StreamSupport) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) Be5Exception(com.developmentontheedge.be5.api.exceptions.Be5Exception) Module(com.developmentontheedge.be5.metadata.model.Module) TableDef(com.developmentontheedge.be5.metadata.model.TableDef) DataElementUtils(com.developmentontheedge.be5.metadata.model.DataElementUtils) Localizations(com.developmentontheedge.be5.metadata.model.Localizations) BeCaseInsensitiveCollection(com.developmentontheedge.be5.metadata.model.base.BeCaseInsensitiveCollection) Predicate(java.util.function.Predicate) Timestamp(java.sql.Timestamp) Set(java.util.Set) Collectors(java.util.stream.Collectors) Date(java.sql.Date) Objects(java.util.Objects) List(java.util.List) ColumnDef(com.developmentontheedge.be5.metadata.model.ColumnDef) RoleSet(com.developmentontheedge.be5.metadata.model.RoleSet) SqlColumnType(com.developmentontheedge.be5.metadata.model.SqlColumnType) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Project(com.developmentontheedge.be5.metadata.model.Project) Collections(java.util.Collections) EntityType(com.developmentontheedge.be5.metadata.model.EntityType) Entity(com.developmentontheedge.be5.metadata.model.Entity) ArrayList(java.util.ArrayList) Module(com.developmentontheedge.be5.metadata.model.Module)

Example 3 with EntityType

use of com.developmentontheedge.be5.metadata.model.EntityType in project be5 by DevelopmentOnTheEdge.

the class Menu method generateMenu.

private MenuResponse generateMenu(Injector injector, boolean withIds, EntityType entityType) {
    UserAwareMeta userAwareMeta = injector.get(UserAwareMeta.class);
    List<String> roles = UserInfoHolder.getCurrentRoles();
    String language = UserInfoHolder.getLanguage();
    List<RootNode> entities = collectEntities(injector.getMeta(), userAwareMeta, language, roles, withIds, entityType);
    return new MenuResponse(entities);
}
Also used : UserAwareMeta(com.developmentontheedge.be5.api.helpers.UserAwareMeta)

Example 4 with EntityType

use of com.developmentontheedge.be5.metadata.model.EntityType in project be5 by DevelopmentOnTheEdge.

the class Menu method getDefaultAction.

private Action getDefaultAction(Injector injector, EntityType entityType) {
    UserAwareMeta userAwareMeta = injector.get(UserAwareMeta.class);
    List<String> roles = UserInfoHolder.getCurrentRoles();
    String language = UserInfoHolder.getLanguage();
    List<RootNode> entities = collectEntities(injector.getMeta(), userAwareMeta, language, roles, false, entityType);
    for (RootNode rootNode : entities) {
        if (rootNode.action != null) {
            if (rootNode.isDefault)
                return rootNode.action;
        } else if (rootNode.children != null) {
            for (QueryNode node : rootNode.children) {
                if (node.isDefault)
                    return node.action;
            }
        }
    }
    for (RootNode rootNode : entities) {
        if (rootNode.action != null) {
            return rootNode.action;
        } else if (rootNode.children != null) {
            for (QueryNode node : rootNode.children) {
                return node.action;
            }
        }
    }
    return null;
}
Also used : UserAwareMeta(com.developmentontheedge.be5.api.helpers.UserAwareMeta)

Aggregations

UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)2 Entity (com.developmentontheedge.be5.metadata.model.Entity)2 Module (com.developmentontheedge.be5.metadata.model.Module)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Be5ErrorCode (com.developmentontheedge.be5.api.exceptions.Be5ErrorCode)1 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)1 Meta (com.developmentontheedge.be5.api.services.Meta)1 ProjectProvider (com.developmentontheedge.be5.api.services.ProjectProvider)1 QueryLink (com.developmentontheedge.be5.api.services.QueryLink)1 RoleType (com.developmentontheedge.be5.metadata.RoleType)1 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)1 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)1 DataElementUtils (com.developmentontheedge.be5.metadata.model.DataElementUtils)1 EntityItem (com.developmentontheedge.be5.metadata.model.EntityItem)1 EntityLocalizations (com.developmentontheedge.be5.metadata.model.EntityLocalizations)1 EntityType (com.developmentontheedge.be5.metadata.model.EntityType)1 LanguageLocalizations (com.developmentontheedge.be5.metadata.model.LanguageLocalizations)1 LocalizationElement (com.developmentontheedge.be5.metadata.model.LocalizationElement)1