use of com.developmentontheedge.be5.model.StaticPagePresentation in project be5 by DevelopmentOnTheEdge.
the class QueryBuilder method insert.
private void insert(String sql, Injector injector) {
Object id = injector.getSqlService().insert(sql);
resourceDataList.add(new ResourceData("result", FrontendConstants.STATIC_ACTION, new StaticPagePresentation("Insert was successful", "New primaryKey: " + id), null));
}
use of com.developmentontheedge.be5.model.StaticPagePresentation 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.model.StaticPagePresentation in project be5 by DevelopmentOnTheEdge.
the class QueryBuilder method update.
private void update(String sql, Injector injector) {
Object id = injector.getSqlService().update(sql);
resourceDataList.add(new ResourceData("result", FrontendConstants.STATIC_ACTION, new StaticPagePresentation("Update was successful", id + " row(s) affected"), null));
}
use of com.developmentontheedge.be5.model.StaticPagePresentation in project be5 by DevelopmentOnTheEdge.
the class StaticPageComponent method generate.
@Override
public void generate(Request req, Response res, Injector injector) {
String language = UserInfoHolder.getLanguage();
String page = req.getRequestUri();
String staticPageContent = injector.getProject().getStaticPageContent(language, page);
if (staticPageContent == null) {
// todo localize
res.sendErrorAsJson(new ErrorModel("500", ErrorTitles.formatTitle(Be5ErrorCode.NOT_FOUND, page), Collections.singletonMap(SELF_LINK, "static/" + page)), req.getDefaultMeta());
} else {
res.sendAsJson(new ResourceData(STATIC_ACTION, new StaticPagePresentation("", staticPageContent), Collections.singletonMap(SELF_LINK, "static/" + page)), req.getDefaultMeta());
}
}
use of com.developmentontheedge.be5.model.StaticPagePresentation in project be5 by DevelopmentOnTheEdge.
the class StaticPageComponentTest method generate.
@Test
public void generate() throws Exception {
Response response = mock(Response.class);
String page = "info.be";
Request req = getSpyMockRequest(page, ImmutableMap.of(TIMESTAMP_PARAM, "123456789"));
component.generate(req, response, injector);
// todo verify(response).sendAsJson(eq(new ResourceData(STATIC_ACTION,
// new StaticPagePresentation("", "<h1>Info</h1><p>Test text.</p>"))),
// eq(ImmutableMap.of(TIMESTAMP_PARAM, "123456789")),
// eq(Collections.singletonMap(SELF_LINK, "static/" + page)));
verify(response).sendAsJson(any(ResourceData.class), any(Map.class));
}
Aggregations