use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class DateTimeTest method testOperation.
@Test
public void testOperation() {
Operation operation = createOperation("dateTime", "All records", "Insert", "0");
ImmutableMap<String, Object> values = ImmutableMap.of("activeFrom", "1901-02-03");
Either<Object, OperationResult> generate = generateOperation(operation, values);
Object parameters = generate.getFirst();
assertEquals("{" + "'values':{'activeFrom':'1901-02-03'}," + "'meta':{'/activeFrom':{'displayName':'activeFrom','type':'Date'}}," + "'order':['/activeFrom']" + "}", oneQuotes(JsonFactory.bean(parameters)));
OperationResult result = executeOperation(operation, values).getSecond();
assertEquals(OperationResult.redirect("table/dateTime/All records"), result);
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class ResponseImpl method sendError.
// @Override
// public void sendErrorsAsJson(Object[] errors, Object meta)
// {
// throw new RuntimeException("");
// //TODO create ErrorObject, sendAsRawJson(new JsonApiModel(errors, meta, links));
// }
@Override
public void sendError(Be5Exception e) {
ErrorModel errorModel;
if (UserInfoHolder.isSystemDeveloper()) {
errorModel = new ErrorModel(e);
} else {
errorModel = new ErrorModel(e.getHttpStatusCode(), "");
}
sendErrorAsJson(errorModel, null);
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class GdslGenegator method createService.
private void createService(String generatedSourcesPath, String packageName, String serviceClassName, Configuration cfg) throws IOException {
Template serviceTpl = cfg.getTemplate("gdsl/entities.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<>();
entityCount = entities.size();
for (Entity entity : entities) {
if (entity.getName().startsWith("_"))
continue;
// groovy have getProperties()
if (entity.getName().equals("properties"))
continue;
entityNames.add(entity.getName());
}
input.put("entityNames", entityNames);
Utils.createFile(generatedSourcesPath, packageName, serviceClassName + ".gdsl", serviceTpl, input);
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class Menu method generateEntityQueries.
private List<QueryNode> generateEntityQueries(List<Query> permittedQueries, String language, Meta meta, boolean withIds) {
List<OrderedQuery> queries = new ArrayList<>();
for (Query permittedQuery : permittedQueries) {
queries.add(new OrderedQuery(permittedQuery, meta.getTitle(permittedQuery, language)));
}
Collections.sort(queries);
List<QueryNode> children = new ArrayList<>();
for (OrderedQuery query : queries) {
Query permittedQuery = query.query;
Id id = null;
if (withIds) {
id = new Id(permittedQuery.getEntity().getName(), permittedQuery.getName());
}
children.add(new QueryNode(id, query.title, ActionUtils.toAction(permittedQuery), permittedQuery.isDefaultView()));
}
return children;
}
use of com.developmentontheedge.be5.api.services.Meta in project be5 by DevelopmentOnTheEdge.
the class Menu method collectEntityContent.
private void collectEntityContent(Entity entity, String language, Meta meta, UserAwareMeta userAwareMeta, List<String> roles, boolean withIds, List<RootNode> out) {
List<Query> permittedQueries = meta.getQueries(entity, roles);
if (permittedQueries.isEmpty()) {
return;
}
String title = meta.getTitle(entity, language);
List<OperationNode> operations = generateEntityOperations(entity, meta, userAwareMeta, roles, withIds);
if (operations.isEmpty()) {
operations = null;
}
if (canBeMovedToRoot(permittedQueries, title, language, meta)) {
// Query in the root, contains an action.
Id id = null;
Action action = ActionUtils.toAction(permittedQueries.get(0));
boolean isDefault = permittedQueries.get(0).isDefaultView();
if (withIds) {
String queryTitle = getTitleOfRootQuery(permittedQueries, title, language, meta);
id = new Id(entity.getName(), queryTitle);
}
out.add(RootNode.action(id, title, isDefault, action, operations));
} else {
// No query in the root, just inner queries.
List<QueryNode> children = generateEntityQueries(permittedQueries, language, meta, withIds);
Id id = new Id(entity.getName(), null);
out.add(RootNode.container(id, title, children, operations));
}
}
Aggregations