support group filter
parent
56e08ede2b
commit
daef12d048
|
|
@ -16,6 +16,7 @@ import com.nttdata.calender.errorhandling.ErrorTypes.NotFoundError;
|
|||
public class SupportGroup {
|
||||
private static final String formName = "CTM:Support Group";
|
||||
private static final String formAssoc = "CTM:Support Group Assoc LookUp";
|
||||
private static final String formLookUp = "CTM:PeopleUserSupportGroupFunctionalRoleLookup";
|
||||
private static final SupportGroup INSTANCE = new SupportGroup();
|
||||
private ArrayList<SupportGroupGetResponse> supportGroups;
|
||||
private SupportGroupGetResponse userSupportGroup;
|
||||
|
|
@ -46,54 +47,40 @@ public class SupportGroup {
|
|||
public void querySupportGroups(RemedyJavaAPI api) throws ARException, NotFoundError {
|
||||
|
||||
api.impersonateUser("btwien_test");
|
||||
var querySupportGroups = new Query.QueryBuilder(formAssoc)
|
||||
var querySupportGroups = new Query.QueryBuilder(formLookUp)
|
||||
.addFieldId("SupportGroup", 1000000015)
|
||||
.addFieldId("SupportGroupId", 1000000079)
|
||||
.addFieldId("FunctionalRole", 1000000172)
|
||||
.build();
|
||||
|
||||
System.out.println(api.isAdministrator());
|
||||
if (api.isAdministrator()) {
|
||||
this.supportGroups = api
|
||||
.queryFieldsById("\'1000001859\' == 5000 OR \'1000001859\' == 6000",
|
||||
querySupportGroups.getFieldIds(),
|
||||
querySupportGroups.getFormName(), null, 0, 0)
|
||||
.stream()
|
||||
.map(entry -> new SupportGroupGetResponse(
|
||||
entry.get(querySupportGroups.getFieldId("SupportGroup")).toString(),
|
||||
entry.get(querySupportGroups.getFieldId("SupportGroupId")).toString()))
|
||||
.distinct()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
this.supportGroups = api
|
||||
.queryFieldsById("\'1000000172\' == 5000 OR \'1000000172\' == 6000", querySupportGroups.getFieldIds(),
|
||||
querySupportGroups.getFormName(), null, 0, 0)
|
||||
.stream()
|
||||
.map(entry -> new SupportGroupGetResponse(
|
||||
entry.get(querySupportGroups.getFieldId("SupportGroup")).toString(),
|
||||
entry.get(querySupportGroups.getFieldId("SupportGroupId")).toString()))
|
||||
.distinct()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
// nur zum testen
|
||||
var test = api
|
||||
.queryFieldsById("\'1000000172\' == 5000 OR \'1000000172\' == 6000", querySupportGroups.getFieldIds(),
|
||||
querySupportGroups.getFormName(), null, 0, 0);
|
||||
for (var t : test)
|
||||
System.out.println(t);
|
||||
|
||||
// ALLE SUPPORTGRUPPEN
|
||||
// this.supportGroups = api
|
||||
// .queryFieldsById("\'4\' != \"_\"", querySupportGroups.getFieldIds(),
|
||||
// querySupportGroups.getFormName(), null, 0, 0)
|
||||
// .stream()
|
||||
// .map(entry -> new SupportGroupGetResponse(
|
||||
// entry.get(querySupportGroups.getFieldId("SupportGroup")).toString(),
|
||||
// entry.get(querySupportGroups.getFieldId("SupportGroupId")).toString()))
|
||||
// .distinct()
|
||||
// .collect(Collectors.toCollection(ArrayList::new));
|
||||
} else {
|
||||
this.supportGroups = api
|
||||
.queryFieldsById("\'4\' == \"" + api.getUser() + "\" AND (\'1000001859\' == 5000 OR \'1000001859\' == 6000)",
|
||||
querySupportGroups.getFieldIds(),
|
||||
querySupportGroups.getFormName(), null, 0, 0)
|
||||
.stream()
|
||||
.map(entry -> new SupportGroupGetResponse(
|
||||
entry.get(querySupportGroups.getFieldId("SupportGroup")).toString(),
|
||||
entry.get(querySupportGroups.getFieldId("SupportGroupId")).toString()))
|
||||
.distinct()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
if (this.supportGroups.isEmpty()) {
|
||||
throw new NotFoundError("No support groups found in this context");
|
||||
}
|
||||
|
||||
// System.out.println("NEUE ABFRAGE");
|
||||
// var a = new Query.QueryBuilder("CTM:PeopleUserSupportGroupFunctionalRoleLookup")
|
||||
// .addFieldId("SupportGroupId", 1000000015).build();
|
||||
|
||||
// var q = api.queryFieldsById("\'1000000015\' != \"_\"", a.getFieldIds(), a.getFormName(), null, 0, 0);
|
||||
// System.out.println(q);
|
||||
|
||||
|
||||
api.freeImpersonatedUser();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue