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;
}
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;
}
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());
}
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;
}
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);
}
Aggregations