Search in sources :

Example 6 with BeModelElement

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

the class DpsHelper method addTags.

private <T extends DynamicPropertySet> T addTags(T dps, BeModelElement modelElements, Collection<String> columnNames) {
    Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
    for (String propertyName : columnNames) {
        DynamicProperty property = dps.getProperty(propertyName);
        ColumnDef columnDef = columns.get(property.getName());
        if (columnDef != null)
            addTags(property, columnDef);
    }
    return dps;
}
Also used : DynamicProperty(com.developmentontheedge.beans.DynamicProperty) ColumnDef(com.developmentontheedge.be5.metadata.model.ColumnDef)

Example 7 with BeModelElement

use of com.developmentontheedge.be5.metadata.model.base.BeModelElement 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 8 with BeModelElement

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

the class Project method getContext.

/**
 * Creates and returns FreeMarker context for given element
 * @param element to create context for (can be null)
 * @return
 */
public Map<String, Object> getContext(TemplateElement element) {
    Map<String, Object> context = new HashMap<>();
    BeModelElement parent = element;
    while (parent != null) {
        if (parent instanceof PageCustomization) {
            context.put("customization", parent);
        } else if (parent instanceof Query) {
            context.put("query", parent);
        } else if (parent instanceof Operation) {
            context.put("operation", parent);
        } else if (parent instanceof Entity) {
            context.put("entity", parent);
        } else if (parent instanceof Module) {
            context.put("module", parent);
        }
        parent = parent.getOrigin();
    }
    for (String name : getPropertyNames()) {
        context.put(name, getProperty(name));
    }
    BeConnectionProfile profile = getConnectionProfile();
    if (profile != null) {
        for (String name : profile.getPropertyNames()) {
            context.put(name, profile.getProperty(name));
        }
    }
    return context;
}
Also used : BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 9 with BeModelElement

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

the class DataElementUtils method moveBackToItsModule.

/**
 * Moves the model element back to the its module if the element is an entity item.
 *
 * @param modelElement
 */
public static void moveBackToItsModule(final BeModelElement modelElement) {
    if (modelElement instanceof BeElementWithOriginModule) {
        BeElementWithOriginModule r = (BeElementWithOriginModule) modelElement;
        r.setOriginModuleName(r.getModule().getName());
    }
}
Also used : BeElementWithOriginModule(com.developmentontheedge.be5.metadata.model.base.BeElementWithOriginModule)

Example 10 with BeModelElement

use of com.developmentontheedge.be5.metadata.model.base.BeModelElement 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

BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)9 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)8 DynamicProperty (com.developmentontheedge.beans.DynamicProperty)7 BeModelCollection (com.developmentontheedge.be5.metadata.model.base.BeModelCollection)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)2 Entity (com.developmentontheedge.be5.metadata.model.Entity)2 Project (com.developmentontheedge.be5.metadata.model.Project)2 BeElementWithOriginModule (com.developmentontheedge.be5.metadata.model.base.BeElementWithOriginModule)2 Timestamp (java.sql.Timestamp)2 Date (java.util.Date)2 Map (java.util.Map)2 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)1 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)1 GroovyOperation (com.developmentontheedge.be5.metadata.model.GroovyOperation)1 JavaOperation (com.developmentontheedge.be5.metadata.model.JavaOperation)1 BeCaseInsensitiveCollection (com.developmentontheedge.be5.metadata.model.base.BeCaseInsensitiveCollection)1 Field (com.developmentontheedge.be5.metadata.serialization.Field)1