Search in sources :

Example 1 with BeModelCollection

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

the class YamlDeserializer method reloadEntity.

public Entity reloadEntity(final Entity oldEntity) throws ReadException {
    this.fileSystem = new ProjectFileSystem(oldEntity.getProject());
    this.setProject(oldEntity.getProject());
    final Entity entity = this.readEntity(oldEntity.getModule(), oldEntity.getName());
    if (oldEntity.getPrototype() != null) {
        @SuppressWarnings("unchecked") final BeModelCollection<BeModelElement> prototype = (BeModelCollection<BeModelElement>) oldEntity.getPrototype();
        entity.merge(prototype, true, true);
    }
    EntitiesFactory.addToModule(entity, oldEntity.getModule());
    return entity;
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem) Entity(com.developmentontheedge.be5.metadata.model.Entity) BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement) BeModelCollection(com.developmentontheedge.be5.metadata.model.base.BeModelCollection)

Example 2 with BeModelCollection

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

the class YamlSerializer method serializeCustomizations.

private Map<String, Object> serializeCustomizations(final BeVectorCollection<?> parent) {
    final Map<String, Object> serializedCustomizations = map();
    final BeModelCollection<PageCustomization> customiazations = parent.getCollection(PageCustomization.CUSTOMIZATIONS_COLLECTION, PageCustomization.class);
    if (customiazations != null) {
        final String projectOrigin = parent.getProject().getProjectOrigin();
        for (final PageCustomization customization : customiazations) {
            if (!projectOrigin.equals(customization.getOriginModuleName()))
                continue;
            final String name = customization.getDomain() + "." + customization.getType();
            final Map<String, Object> serializedCustomization = map();
            final List<String> serializedRoles = list(customization.getRoles());
            if (!serializedRoles.isEmpty())
                serializedCustomization.put(ATTR_ROLES, serializedRoles);
            serializedCustomization.put(TAG_CODE, customization.getCode());
            serializedCustomizations.put(name, serializedCustomization);
        }
    }
    return serializedCustomizations;
}
Also used : PageCustomization(com.developmentontheedge.be5.metadata.model.PageCustomization)

Example 3 with BeModelCollection

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

the class ModuleUtilsTest method testMergeAllModules.

@Test
public void testMergeAllModules() throws Exception {
    Project module = getModule();
    Project app = getProject();
    LoadContext ctx = new LoadContext();
    ModuleLoader2.mergeAllModules(app, Collections.singletonList(module), ctx);
    ctx.check();
    assertEquals(Collections.singleton("mentity"), app.getEntityNames());
    assertEquals(EntityType.DICTIONARY, app.getEntity("mentity").getType());
    BeModelCollection<Query> queries = app.getEntity("mentity").getQueries();
    assertEquals("QUERY1 customized", queries.get("q1").getQuery());
    assertEquals("Query1 title", queries.get("q1").getTitleName());
    assertEquals("QUERY2", queries.get("q2").getQuery());
    assertEquals("Query2 title", queries.get("q2").getTitleName());
    assertEquals("QUERY3", queries.get("q3").getQuery());
    assertEquals("Query3 title", queries.get("q3").getTitleName());
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) Query(com.developmentontheedge.be5.metadata.model.Query) LoadContext(com.developmentontheedge.be5.metadata.serialization.LoadContext) Test(org.junit.Test)

Example 4 with BeModelCollection

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

the class Project method dump.

public static StringBuffer dump(BeModelCollection<?> collection, StringBuffer msg, String prefix, String shift) {
    final String nl = System.getProperty("line.separator");
    msg.append(prefix + collection.getName() + "[" + collection.getSize() + "], " + collection.getCompletePath() + nl);
    final String newPrefix = prefix + shift;
    for (BeModelElement de : collection) {
        if (de instanceof BeModelCollection) {
            dump((BeModelCollection<?>) de, msg, newPrefix, shift);
        } else {
            msg.append(newPrefix + de.getName() + nl);
        }
    }
    return msg;
}
Also used : BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement) BeModelCollection(com.developmentontheedge.be5.metadata.model.base.BeModelCollection)

Example 5 with BeModelCollection

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

the class DataElementUtils method traversePath.

// pathIterator is mutable, but it's OK as we can see each its element (pathPart)
private static BeModelElement traversePath(Iterator<String> pathIterator, BeModelElement node) {
    assert pathIterator != null;
    assert node != null;
    if (!pathIterator.hasNext())
        // found
        return node;
    final String pathPart = pathIterator.next();
    if (!(node instanceof BeModelCollection))
        // need but can't go further
        return null;
    @SuppressWarnings("unchecked") final BeModelCollection<BeModelElement> collection = (BeModelCollection<BeModelElement>) node;
    if (!collection.contains(pathPart))
        // not found
        return null;
    final BeModelElement nextNode = collection.get(pathPart);
    return traversePath(pathIterator, nextNode);
}
Also used : BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement) BeModelCollection(com.developmentontheedge.be5.metadata.model.base.BeModelCollection)

Aggregations

Entity (com.developmentontheedge.be5.metadata.model.Entity)4 Project (com.developmentontheedge.be5.metadata.model.Project)4 Test (org.junit.Test)4 Module (com.developmentontheedge.be5.metadata.model.Module)3 Query (com.developmentontheedge.be5.metadata.model.Query)3 BeModelCollection (com.developmentontheedge.be5.metadata.model.base.BeModelCollection)3 BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)3 Operation (com.developmentontheedge.be5.metadata.model.Operation)2 Path (java.nio.file.Path)2 JavaScriptOperationExtender (com.developmentontheedge.be5.metadata.model.JavaScriptOperationExtender)1 OperationExtender (com.developmentontheedge.be5.metadata.model.OperationExtender)1 PageCustomization (com.developmentontheedge.be5.metadata.model.PageCustomization)1 RoleGroup (com.developmentontheedge.be5.metadata.model.RoleGroup)1 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)1 ProjectFileSystem (com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1