use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class QueryParser method buildCountSql.
/**
* @param pkName
* @return
*/
private String buildCountSql(String pkName) {
List<String> counts = new ArrayList<>();
counts.add(String.format("count(%s)", pkName));
countFields = new ArrayList<>();
countFields.add(Collections.emptyMap());
if (queryExpr.getBooleanValue("statsField")) {
ConfigBean cb = DataListManager.instance.getListStatsField(UserService.SYSTEM_USER, entity.getName());
if (cb != null && cb.getJSON("config") != null) {
JSONArray items = ((JSONObject) cb.getJSON("config")).getJSONArray("items");
for (Object o : items) {
JSONObject item = (JSONObject) o;
String field = item.getString("field");
if (MetadataHelper.checkAndWarnField(entity, field)) {
counts.add(String.format("%s(%s)", item.getString("calc"), field));
countFields.add(item);
}
}
}
}
return String.format("select %s from %s where ", StringUtils.join(counts, ","), entity.getName());
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectManagerTest method testCreateTask.
@Test
public void testCreateTask() {
ConfigBean[] plans = ProjectManager.instance.getPlansOfProject(_LastSavedProject);
Record task = EntityHelper.forNew(EntityHelper.ProjectTask, SIMPLE_USER);
task.setID("projectId", _LastSavedProject);
task.setID("projectPlanId", plans[0].getID("id"));
task.setString("taskName", "任务" + System.currentTimeMillis());
task = Application.getBean(ProjectTaskService.class).create(task);
System.out.println("New task created : " + task.getPrimary());
Assertions.assertTrue(ProjectHelper.checkReadable(task.getPrimary(), SIMPLE_USER));
Assertions.assertTrue(ProjectHelper.isManageable(task.getPrimary(), SIMPLE_USER));
// DELETE
Application.getBean(ProjectTaskService.class).delete(task.getPrimary());
}
Aggregations