use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class DatabaseModel method getEntity.
@Override
public EntityModel getEntity(String entityName) {
Objects.requireNonNull(entityName);
Entity entity = meta.getEntity(entityName);
if (entity == null)
throw Be5Exception.unknownEntity(entityName);
return new EntityModelBase(sqlService, dpsHelper, validator, operationHelper, operationExecutor, meta, entity);
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class ProjectFileSystemTest method testPathsMap.
@Test
public void testPathsMap() throws IOException {
Project prj = new Project("test");
Path root = tmp.newFolder().toPath();
prj.setLocation(root);
ProjectFileSystem pfs = new ProjectFileSystem(prj);
Map<Path, Boolean> map = EntryStream.of(pfs.getPaths()).mapKeys(root::relativize).toSortedMap();
assertTrue(StreamEx.of("", "src", "src/js/extenders", "src/js/forms", "src/js/operations", "src/js/queries", "src/l10n", "src/meta/data", "src/meta/entities").map(Paths::get).noneMatch(map::get));
assertTrue(StreamEx.of("src/ftl", "src/include", "src/meta/modules", "src/groovy/operations", "src/pages").map(Paths::get).allMatch(map::get));
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class EntityModels method createEntities.
// private String artifactIdToPackage(String path)
// {
// StringBuilder s = new StringBuilder();
// boolean toUpperCase = false;
// path = path.toLowerCase();
// for (int i = 0; i < path.length(); i++)
// {
// if(path.charAt(i) == '-')
// {
// toUpperCase = true;
// continue;
// }
// if(toUpperCase){
// s.append(Character.toUpperCase(path.charAt(i)));
// toUpperCase = false;
// }else{
// s.append(path.charAt(i));
// }
// }
//
// return s.toString();
// }
private void createEntities(String generatedSourcesPath, String packageName, Configuration cfg) throws IOException {
Template entityTpl = cfg.getTemplate("entity.ftl");
Meta meta = injector.getMeta();
List<Entity> entities = meta.getOrderedEntities("ru");
for (Entity entity : entities) {
if (entity.getName().startsWith("_"))
continue;
String entityClassName = Strings.capitalize(entity.getName());
Map<String, Object> input = new HashMap<>();
input.put("entityClassName", entityClassName);
input.put("packageName", packageName);
Map<String, ColumnDef> columns = meta.getColumns(entity);
List<ColumnsInfo> columnsInfos = new ArrayList<>();
for (ColumnDef columnDef : columns.values()) {
columnsInfos.add(new ColumnsInfo(columnDef.getName(), meta.getColumnType(columnDef).getSimpleName()));
}
input.put("columns", columnsInfos);
Utils.createFile(generatedSourcesPath, packageName, entityClassName + ".java", entityTpl, input);
entityCount++;
}
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class EntityModels method createService.
private void createService(String generatedSourcesPath, String packageName, String serviceClassName, Configuration cfg) throws IOException {
Template serviceTpl = cfg.getTemplate("service.ftl");
Meta meta = injector.getMeta();
List<Entity> entities = meta.getOrderedEntities("ru");
Map<String, Object> input = new HashMap<>();
input.put("serviceClassName", serviceClassName);
input.put("packageName", packageName);
List<String> entityNames = new ArrayList<>();
for (Entity entity : entities) {
if (entity.getName().startsWith("_"))
continue;
entityNames.add(entity.getName());
}
input.put("entityNames", entityNames);
Utils.createFile(generatedSourcesPath, packageName, serviceClassName + ".java", serviceTpl, input);
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class Menu method generateEntityOperations.
private List<OperationNode> generateEntityOperations(Entity entity, Meta meta, UserAwareMeta userAwareMeta, List<String> roles, boolean withIds) {
List<OperationNode> operations = new ArrayList<>();
Query allRecords = entity.getQueries().get(DatabaseConstants.ALL_RECORDS_VIEW);
String insertOperationName = INSERT_OPERATION;
if (allRecords != null && allRecords.getOperationNames().getFinalValues().contains(insertOperationName)) {
Operation insertOperation = entity.getOperations().get(insertOperationName);
if (insertOperation != null && meta.isAvailableFor(insertOperation, roles)) {
String title = userAwareMeta.getLocalizedOperationTitle(entity.getName(), insertOperationName);
Action action = ActionUtils.toAction(DatabaseConstants.ALL_RECORDS_VIEW, insertOperation);
OperationId id = withIds ? new OperationId(entity.getName(), insertOperationName) : null;
OperationNode operation = new OperationNode(id, title, action);
operations.add(operation);
}
}
return operations;
}
Aggregations