Search in sources :

Example 16 with BeModelElement

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

the class DpsHelper method addDpsExcludedColumnsWithoutTags.

public <T extends DynamicPropertySet> T addDpsExcludedColumnsWithoutTags(T dps, BeModelElement modelElements, Collection<String> excludedColumns) {
    Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
    ArrayList<String> excludedColumnsList = new ArrayList<>(excludedColumns);
    for (Map.Entry<String, ColumnDef> entry : columns.entrySet()) {
        if (!excludedColumnsList.contains(entry.getKey())) {
            DynamicProperty dynamicProperty = getDynamicPropertyWithoutTags(entry.getValue(), modelElements);
            dps.add(dynamicProperty);
        }
        excludedColumnsList.remove(entry.getKey());
    }
    for (String propertyName : excludedColumnsList) {
        log.warning("Column " + propertyName + " not found in " + modelElements.getName());
    }
    return dps;
}
Also used : DynamicProperty(com.developmentontheedge.beans.DynamicProperty) ArrayList(java.util.ArrayList) ColumnDef(com.developmentontheedge.be5.metadata.model.ColumnDef) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 17 with BeModelElement

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

the class DpsHelper method checkDpsColumns.

public void checkDpsColumns(BeModelElement modelElements, DynamicPropertySet dps) {
    StringBuilder errorMsg = new StringBuilder();
    Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
    for (ColumnDef column : columns.values()) {
        if (!column.isCanBeNull() && !column.isAutoIncrement() && column.getDefaultValue() == null && !dps.hasProperty(column.getName())) {
            errorMsg.append("Dps not contain notNull column '").append(column.getName()).append("'\n");
        }
    }
    for (DynamicProperty property : dps) {
        if (!columns.keySet().contains(property.getName())) {
            errorMsg.append("Entity not contain column '").append(property.getName()).append("'\n");
        }
    }
    if (!errorMsg.toString().isEmpty()) {
        throw Be5Exception.internal("Dps columns errors for modelElements '" + modelElements.getName() + "'\n" + errorMsg);
    }
}
Also used : DynamicProperty(com.developmentontheedge.beans.DynamicProperty) ColumnDef(com.developmentontheedge.be5.metadata.model.ColumnDef)

Example 18 with BeModelElement

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

the class DpsHelper method addDpForColumnsWithoutTags.

public <T extends DynamicPropertySet> T addDpForColumnsWithoutTags(T dps, BeModelElement modelElements, Collection<String> columnNames) {
    Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
    for (String propertyName : columnNames) {
        ColumnDef columnDef = columns.get(propertyName);
        if (columnDef != null) {
            DynamicProperty dynamicProperty = getDynamicPropertyWithoutTags(columnDef, modelElements);
            dps.add(dynamicProperty);
        } else {
            throw Be5Exception.internal("Entity '" + modelElements.getName() + "' not contain column " + propertyName);
        }
    }
    return dps;
}
Also used : DynamicProperty(com.developmentontheedge.beans.DynamicProperty) ColumnDef(com.developmentontheedge.be5.metadata.model.ColumnDef)

Example 19 with BeModelElement

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

the class Project method getModulesAndApplication.

public List<Module> getModulesAndApplication() {
    List<Module> result = getModules().stream().toList();
    BeModelElement appElement = get(getProjectOrigin());
    if (appElement instanceof Module)
        result.add((Module) appElement);
    return result;
}
Also used : BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement)

Example 20 with BeModelElement

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

the class BeModelElementSupport method mergeThis.

protected void mergeThis(BeModelElement other, boolean inherit) {
    if (inherit) {
        this.prototype = other;
    } else {
        this.prototype = null;
        Set<String> customizableProperties = new HashSet<>(getCustomizableProperties());
        customizableProperties.removeAll(getCustomizedProperties());
        for (String customizableProperty : customizableProperties) {
            try {
                Object value = Beans.getBeanPropertyValue(other, customizableProperty);
                ComponentModel info = ComponentFactory.getModel(this, ComponentFactory.Policy.DEFAULT);
                Property property = info.findProperty(customizableProperty);
                if (property != null) {
                    if (!customizableProperty.equals("roles")) {
                        property.setValue(value);
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
Also used : ComponentModel(com.developmentontheedge.beans.model.ComponentModel) Property(com.developmentontheedge.beans.model.Property) ProjectElementException(com.developmentontheedge.be5.metadata.exception.ProjectElementException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

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