use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class Be5QueryExecutor method resolveTypeOfRefColumn.
private void resolveTypeOfRefColumn(AstStart ast) {
ast.tree().select(AstBeParameterTag.class).forEach(tag -> {
if (tag.getRefColumn() != null) {
String[] split = tag.getRefColumn().split("\\.");
String table, column;
if (split.length == 2) {
table = split[0];
column = split[1];
} else if (split.length == 3) {
table = split[0] + "." + split[1];
column = split[2];
} else {
return;
}
Entity entity = meta.getEntity(table);
if (entity != null) {
tag.setType(meta.getColumnType(entity, column).getName());
}
}
});
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class QueryBuilder method select.
private void select(String sql, Request req, Injector injector) {
DocumentGenerator documentGenerator = injector.get(DocumentGenerator.class);
String userQBuilderQueryName = UserInfoHolder.getUserName() + "Query";
Map<String, String> parametersMap = req.getValuesFromJsonAsStrings(RestApiConstants.VALUES);
Entity entity = new Entity(entityName, injector.getProject().getApplication(), EntityType.TABLE);
DataElementUtils.save(entity);
Query query = new Query(userQBuilderQueryName, entity);
query.setType(QueryType.D1_UNKNOWN);
if (sql != null) {
query.setQuery(sql);
}
DataElementUtils.save(query);
try {
resourceDataList.add(new ResourceData("finalSql", FrontendConstants.STATIC_ACTION, new StaticPagePresentation("Final sql", new Be5QueryExecutor(query, parametersMap, injector).getFinalSql()), null));
} catch (Be5Exception e) {
errorModelList.add(new ErrorModel(e));
}
try {
JsonApiModel document = documentGenerator.getDocument(query, parametersMap);
// todo refactor documentGenerator
document.getData().setId("result");
resourceDataList.add(document.getData());
resourceDataList.addAll(Arrays.asList(document.getIncluded()));
} catch (Be5Exception e) {
errorModelList.add(new ErrorModel(e));
}
entity.getOrigin().remove(entityName);
}
use of com.developmentontheedge.be5.metadata.model.Entity 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.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class DataElementUtils method moveBackToItsModule.
/**
* Moves the model element back to the its module if the element is an entity item.
*
* @param modelElement
*/
public static void moveBackToItsModule(final BeModelElement modelElement) {
if (modelElement instanceof BeElementWithOriginModule) {
BeElementWithOriginModule r = (BeElementWithOriginModule) modelElement;
r.setOriginModuleName(r.getModule().getName());
}
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class Serialization method reloadEntity.
public static Entity reloadEntity(final Entity oldEntity) throws ReadException {
checkProject(oldEntity.getProject());
turnOffAutomaticSerialization();
try {
return new YamlDeserializer(new LoadContext()).reloadEntity(oldEntity);
} finally {
turnOnAutomaticSerialization();
}
}
Aggregations