Commit f202a598 authored by Raimbek Egemberdiev's avatar Raimbek Egemberdiev

added new client classes

parent 9a7aad78
......@@ -16,14 +16,14 @@ public class SynergyDepartmentContent {
private List<Position> positions = new ArrayList<Position>();
public static class Department {
public String departmentId;
public String departmentID;
public String departmentName;
public Boolean hasChildDepartments;
public DepartmentHead departmentHead;
}
public static class DepartmentHead {
public String headId;
public String headID;
public String headName;
public List<Position> positions;
}
......
......@@ -18,6 +18,7 @@ public class SynergyPosition {
private String number;
private String salary;
private String vacancies;
private String positionType;
public SynergyPosition() {
}
......@@ -101,4 +102,12 @@ public class SynergyPosition {
public void setVacancies(String vacancies) {
this.vacancies = vacancies;
}
public String getPositionType() {
return positionType;
}
public void setPositionType(String positionType) {
this.positionType = positionType;
}
}
......@@ -8,8 +8,10 @@ import kz.arta.synergy.api.pojo.DocSend;
import kz.arta.synergy.api.pojo.DocumentInfo;
import kz.arta.synergy.api.pojo.SynergyDepartment;
import kz.arta.synergy.api.pojo.SynergyDepartmentContent;
import org.codehaus.jackson.type.TypeReference;
import java.io.IOException;
import java.util.List;
/**
* @author raimbek
......@@ -42,4 +44,36 @@ public class DepartmentsService {
.queryParam("departmentID", departmentId);
return JsonUtils.read(restHttpQuery.doQuery(query), SynergyDepartmentContent.class);
}
public String saveDepartment(SynergyDepartment synergyDepartment) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/departments/save")
.methodPost()
.formParam("nameRu", synergyDepartment.getNameRu())
.formParam("nameKz", synergyDepartment.getNameKz())
.formParam("nameEn", synergyDepartment.getNameEn())
.formParam("positionNameRu", synergyDepartment.getManager().getNameRu())
.formParam("positionNameKz", synergyDepartment.getManager().getNameKz())
.formParam("positionNameEn", synergyDepartment.getManager().getNameEn())
.formParam("pointersCode", synergyDepartment.getPointersCode())
.formParam("number", synergyDepartment.getNumber())
.formParam("departmentID", synergyDepartment.getDepartmentID())
.formParam("parentDepartmentID", synergyDepartment.getParentDepartmentID());
return restHttpQuery.doQuery(query);
}
public String deleteDepartment(String departmentId) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/departments/delete")
.queryParam("departmentID", departmentId);
return restHttpQuery.doQuery(query);
}
public List<String> searchDepartmentsByPointerCode(String pointerCode) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/departments/search")
.queryParam("pointer_code", pointerCode)
.queryParam("deleted", false);
return JsonUtils.read(restHttpQuery.doQuery(query), new TypeReference<List<String>>() {});
}
}
......@@ -7,8 +7,10 @@ import kz.arta.synergy.api.RestHttpQuery;
import kz.arta.synergy.api.pojo.SynergyDepartment;
import kz.arta.synergy.api.pojo.SynergyDepartmentContent;
import kz.arta.synergy.api.pojo.SynergyPosition;
import org.codehaus.jackson.type.TypeReference;
import java.io.IOException;
import java.util.List;
/**
* @author raimbek
......@@ -33,4 +35,34 @@ public class PositionsService {
return JsonUtils.read(restHttpQuery.doQuery(query), SynergyPosition.class);
}
public String savePosition(SynergyPosition position) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/positions/save")
.methodPost()
.formParam("nameRu", position.getNameRu())
.formParam("nameKz", position.getNameKz())
.formParam("nameEn", position.getNameEn())
.formParam("pointersCode", position.getPointersCode())
.formParam("positionID", position.getPositionID())
.formParam("departmentID", position.getDepartmentID())
.formParam("positionType", position.getPositionType())
.formParam("number", position.getNumber());
return restHttpQuery.doQuery(query);
}
public List<String> searchPositionsByPointerCode(String code) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/positions/search")
.queryParam("pointer_code", code)
.queryParam("deleted", false);
return JsonUtils.read(restHttpQuery.doQuery(query), new TypeReference<List<String>>() {});
}
public String appointToPosition(String positionId, String userId) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/positions/appoint")
.queryParam("positionID", positionId)
.queryParam("userID", userId);
return restHttpQuery.doQuery(query);
}
}
package kz.arta.synergy.api.services;
import kz.arta.synergy.api.JsonUtils;
import kz.arta.synergy.api.Query;
import kz.arta.synergy.api.QueryContext;
import kz.arta.synergy.api.RestHttpQuery;
import kz.arta.synergy.api.pojo.SynergyUser;
import org.codehaus.jackson.type.TypeReference;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author raimbek
* @since 14.11.2016
*/
public class UserChooserService {
public static class User {
public String userID;
public String name;
public String position;
}
public static class SearchExtUser {
public String personName;
public String personID;
public String departmentName;
public String positionName;
public Object customFields;
public String lastname;
public String firstname;
public String patronymic;
}
private final RestHttpQuery restHttpQuery;
private UserService userService;
private UserChooserService(QueryContext context) {
this.restHttpQuery = new RestHttpQuery(context);
userService = UserService.newInstance(context);
}
public static UserChooserService newInstance(QueryContext queryContext) {
return new UserChooserService(queryContext);
}
public List<User> getUsers(String search) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/userchooser/search")
.queryParam("search", search)
.queryParam("showAll", true)
.queryParam("recordsCount", 100);
String result = restHttpQuery.doQuery(query);
return JsonUtils.read(result, new TypeReference<List<User>>() {});
}
public List<SearchExtUser> getUsersExt(String search) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/userchooser/search_ext")
.queryParam("search", search)
.queryParam("showAll", true)
.queryParam("showNoPosition", true)
.queryParam("recordsCount", 100);
String result = restHttpQuery.doQuery(query);
return JsonUtils.read(result, new TypeReference<List<SearchExtUser>>() {});
}
public SynergyUser findUserByCode(String searchString, String code) throws IOException {
List<SearchExtUser> users = getUsersExt(searchString);
for (SearchExtUser user : users) {
SynergyUser userInfo = userService.getUserInfo(user.personID);
if (code.equals(userInfo.getCode())) {
return userInfo;
}
}
return null;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment