use of com.developmentontheedge.be5.metadata.model.Operation in project be5 by DevelopmentOnTheEdge.
the class OperationModelBase method generate.
@Override
public Object generate() {
Operation operation = operationExecutor.create(getOperationInfo(), getOperationContext());
operation.setResult(OperationResult.generate());
return operationExecutor.generate(operation, (Map<String, Object>) presetValues);
}
use of com.developmentontheedge.be5.metadata.model.Operation in project be5 by DevelopmentOnTheEdge.
the class DocumentGeneratorImpl method getDocument.
@Override
public JsonApiModel getDocument(Query query, Map<String, String> parameters, int sortColumn, boolean sortDesc) {
Object data = routeAndRun(query, parameters, sortColumn, sortDesc);
HashUrl url = new HashUrl(TABLE_ACTION, query.getEntity().getName(), query.getName()).named(parameters);
List<ResourceData> included = new ArrayList<>();
String topForm = (String) ParseRequestUtils.getValuesFromJson(query.getLayout()).get(TOP_FORM);
if (topForm != null) {
com.developmentontheedge.be5.operation.Operation operation = operationExecutor.create(query.getEntity().getName(), query.getName(), topForm, new String[] {}, parameters);
Either<FormPresentation, OperationResult> dataTopForm = generateForm(operation, Collections.emptyMap());
included.add(new ResourceData(TOP_FORM, dataTopForm.isFirst() ? FORM_ACTION : OPERATION_RESULT, dataTopForm.get(), Collections.singletonMap(SELF_LINK, operation.getUrl().toString())));
}
return JsonApiModel.data(new ResourceData(TABLE_ACTION, data, Collections.singletonMap(SELF_LINK, url.toString())), included.toArray(new ResourceData[0]), null);
}
use of com.developmentontheedge.be5.metadata.model.Operation in project be5 by DevelopmentOnTheEdge.
the class ProjectGenerator method createLoginAndLogoutOperations.
private void createLoginAndLogoutOperations(final Project project) {
final Entity logoutEntity = new Entity("_logout_", project.getApplication(), EntityType.TABLE);
logoutEntity.setDisplayName("Logout");
logoutEntity.setOrder("99");
logoutEntity.setPrimaryKey("dummy");
logoutEntity.getIcon().setSource(Icon.SOURCE_BE);
logoutEntity.getIcon().setName("logout.gif");
final Query logout = new Query("Logout", logoutEntity);
logout.setType(QueryType.STATIC);
logout.getRoles().add('@' + SpecialRoleGroup.ALL_ROLES_EXCEPT_GUEST_GROUP);
logout.setQuery("logout");
DataElementUtils.saveQuiet(logout);
EntitiesFactory.addToModule(logoutEntity, project.getApplication());
Module beModule = project.getModule(SYSTEM_MODULE);
Entity usersEntity = new Entity("users", beModule, EntityType.TABLE);
usersEntity.setOrder("90");
usersEntity.getIcon().setSource("be:people.gif");
DataElementUtils.saveQuiet(usersEntity);
Query loginQuery = new Query("Login", usersEntity);
loginQuery.setType(QueryType.STATIC);
loginQuery.setQuery("login");
loginQuery.getRoles().add("Guest");
DataElementUtils.saveQuiet(loginQuery);
// Query forgotPassword = new Query("Forgot Password?", usersEntity);
// forgotPassword.getRoles().add( "Guest" );
// forgotPassword.setParametrizingOperationName( "Send password" );
// DataElementUtils.saveQuiet( forgotPassword );
// Operation sendPassword = Operation.createOperation( "Send password", Operation.OPERATION_TYPE_JAVA, usersEntity );
// sendPassword.setCode( SendPassword.class.getName() );
// DataElementUtils.saveQuiet( sendPassword );
}
use of com.developmentontheedge.be5.metadata.model.Operation in project be5 by DevelopmentOnTheEdge.
the class StandardOperationsTest method insertOperationInitValues.
@Test
public void insertOperationInitValues() {
Operation operation = createOperation("testtableAdmin", "All records", "Insert", "");
assertEquals(OperationStatus.CREATE, operation.getStatus());
Object first = generateOperation(operation, "{}").getFirst();
assertEquals(OperationStatus.GENERATE, operation.getStatus());
assertEquals("{'name':'','value':''}", oneQuotes(JsonFactory.bean(first).getJsonObject("values").toString()));
}
Aggregations