use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class ProgramActions method createEventProgram.
public ApiResponse createEventProgram(String... orgUnitsIds) {
JsonObject body = new JsonObjectBuilder(buildProgram("WITHOUT_REGISTRATION", null, orgUnitsIds)).build();
ApiResponse response = post(body);
createProgramStage(response.extractUid(), "DEFAULT STAGE");
return response;
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class ProgramActions method addDataElement.
public ApiResponse addDataElement(String programStageId, String dataElementId, boolean isMandatory) {
JsonObject object = programStageActions.get(programStageId, new QueryParamsBuilder().add("fields=*")).getBody();
JsonObjectBuilder.jsonObject(object).addOrAppendToArray("programStageDataElements", new JsonObjectBuilder().addProperty("compulsory", String.valueOf(isMandatory)).addObject("dataElement", new JsonObjectBuilder().addProperty("id", dataElementId)).build());
return programStageActions.update(programStageId, object);
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class ProgramActions method createProgramStage.
/**
* Creates a program stage and links it to the program.
*
* @param programId
* @param programStageName
* @return program stage id
*/
public String createProgramStage(String programId, String programStageName) {
ApiResponse response = programStageActions.post(new JsonObjectBuilder().addProperty("name", programStageName).addObject("program", new JsonObjectBuilder().addProperty("id", programId)).addProperty("publicAccess", "rwrw----").build());
response.validate().statusCode(Matchers.is(Matchers.oneOf(201, 200)));
return response.extractUid();
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class TrackedEntityTypeActions method addAttribute.
public void addAttribute(String tet, String attribute, boolean mandatory) {
JsonObject object = this.get(tet).getBodyAsJsonBuilder().addOrAppendToArray("trackedEntityTypeAttributes", new JsonObjectBuilder().addProperty("mandatory", String.valueOf(mandatory)).addObject("trackedEntityAttribute", new JsonObjectBuilder().addProperty("id", attribute)).build()).build();
this.update(tet, object).validateStatus(200);
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class UserActions method grantUserSearchAccessToOrgUnit.
public void grantUserSearchAccessToOrgUnit(String userId, String orgUnitId) {
JsonObject object = this.get(userId).getBodyAsJsonBuilder().addOrAppendToArray("teiSearchOrganisationUnits", new JsonObjectBuilder().addProperty("id", orgUnitId).build()).build();
ApiResponse response = this.update(userId, object);
response.validate().statusCode(200).body("status", equalTo("OK"));
}
Aggregations