use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class AppValidate method checkQuery.
private void checkQuery() throws MojoFailureException {
if (queryPath == null)
return;
int pos = queryPath.indexOf('.');
if (pos <= 0) {
throw new MojoFailureException("Invalid query path supplied: " + queryPath);
}
String entityName = queryPath.substring(0, pos);
String queryName = queryPath.substring(pos + 1);
Entity entity = be5Project.getEntity(entityName);
if (entity == null) {
throw new MojoFailureException("Invalid entity: " + entityName);
}
Query query = entity.getQueries().get(queryName);
if (query == null) {
try {
queryName = new String(queryName.getBytes("CP866"), "CP1251");
query = entity.getQueries().get(queryName);
} catch (UnsupportedEncodingException e) {
throw new MojoFailureException("Can not load query, path=" + queryPath, e);
}
}
if (query == null) {
throw new MojoFailureException("Invalid query: " + queryName);
}
getLog().info("Query: " + query.getQueryCompiled().getResult().replaceAll("\n", System.lineSeparator()));
}
use of com.developmentontheedge.be5.metadata.model.Entity 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);
}
}
use of com.developmentontheedge.be5.metadata.model.Entity 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;
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class GroovyOperationLoader method initOperationMap.
void initOperationMap() {
Map<String, com.developmentontheedge.be5.metadata.model.Operation> newOperationMap = new HashMap<>();
List<Entity> entities = meta.getOrderedEntities("ru");
for (Entity entity : entities) {
List<String> operationNames = meta.getOperationNames(entity);
for (String operationName : operationNames) {
com.developmentontheedge.be5.metadata.model.Operation operation = meta.getOperationIgnoringRoles(entity, operationName);
if (operation.getType().equals(OPERATION_TYPE_GROOVY)) {
GroovyOperation groovyOperation = (GroovyOperation) operation;
String fileName = groovyOperation.getFileName().replace("/", ".");
newOperationMap.put(fileName, operation);
}
}
}
groovyOperationsMap = newOperationMap;
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class MetaImpl method createQueryFromSql.
@Override
public Query createQueryFromSql(String sql) {
Entity e = new Entity("be5DynamicQueries", getProject().getApplication(), EntityType.TABLE);
e.setBesql(true);
DataElementUtils.save(e);
Query query = new Query("query", e);
DataElementUtils.save(query);
query.setQuery(sql);
return query;
}
Aggregations