use of com.developmentontheedge.be5.metadata.model.Entity 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.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class ProvincesRepository method toMap.
@Override
public Map<String, Object> toMap(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Provinces.class) final Closure config) {
Provinces entity = new Provinces();
// todo need this
Closure code = config.rehydrate(entity, entity, entity);
code.setResolveStrategy(Closure.DELEGATE_FIRST);
code.call();
return toMap(entity);
}
use of com.developmentontheedge.be5.metadata.model.Entity 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;
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class Query method getErrors.
@Override
public List<ProjectElementException> getErrors() {
List<ProjectElementException> result = super.getErrors();
try {
ModelValidationUtils.checkValueInSet(this, "type", getType().getName(), getQueryTypes());
} catch (ProjectElementException e) {
result.add(e);
}
String templateQueryName = getTemplateQueryName();
if (!templateQueryName.isEmpty()) {
int pos = templateQueryName.indexOf('.');
if (pos < 0) {
result.add(new ProjectElementException(getCompletePath(), "templateQueryName", new IllegalArgumentException("templateQueryName must have format <entity>:<query>")));
}
}
Set<String> missingEntries = getRoles().getMissingEntries();
if (!missingEntries.isEmpty()) {
result.add(new ProjectElementException(getCompletePath(), "roles", "Unknown role(s): " + missingEntries));
}
ProjectElementException error = getQueryCompiled().getError();
if (error != null && !error.isNoError()) {
DataElementPath path = getCompletePath();
if (error.getPath().equals(path.toString()))
result.add(error);
else
result.add(new ProjectElementException(path, "query", error));
}
return result;
}
use of com.developmentontheedge.be5.metadata.model.Entity 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