loggin template, approval logic
parent
625247e270
commit
7e1ca96d30
|
|
@ -0,0 +1,25 @@
|
|||
package com.nttdata.calender;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.bmc.arsys.api.ARException;
|
||||
import com.nttdata.calender.api.RemedyJavaAPI;
|
||||
|
||||
public class LoggerTemplates {
|
||||
private RemedyJavaAPI api;
|
||||
private static final Logger applicationLogger = LogManager.getLogger("application");
|
||||
|
||||
public LoggerTemplates(RemedyJavaAPI api) {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
public void initLog(String requestName, String userName) throws ARException {
|
||||
applicationLogger.info("\n\n\nRequest: " + requestName + "\nUser: " + api.getUser() + "\nAdmin? "
|
||||
+ (this.api.isAdministrator() ? "Yes" : "No"));
|
||||
}
|
||||
|
||||
public void qualifierLog(String form, String qualifier) {
|
||||
applicationLogger.info("\nForm: " + form + "\nQualifier: " + qualifier);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ import java.util.Date;
|
|||
import java.util.Optional;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bmc.arsys.api.ARException;
|
||||
|
|
@ -15,6 +17,7 @@ import com.bmc.arsys.api.SortInfo;
|
|||
import com.bmc.arsys.api.Timestamp;
|
||||
import com.bmc.arsys.api.Value;
|
||||
import com.nttdata.calender.DateConverter;
|
||||
import com.nttdata.calender.LoggerTemplates;
|
||||
import com.nttdata.calender.api.Query;
|
||||
import com.nttdata.calender.api.RemedyJavaAPI;
|
||||
import com.nttdata.calender.changes.query.FilterElement;
|
||||
|
|
@ -63,6 +66,8 @@ public class Change {
|
|||
.addFieldId("Contract", 670031002)
|
||||
.addFieldId("PlanTimeHours", 666000009)
|
||||
.addFieldId("PlanTimeMinutes", 666000010)
|
||||
.addFieldId("Approval", 1000003278)
|
||||
.addFieldId("ApprovalProcessName", 301322300)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +84,8 @@ public class Change {
|
|||
* @throws ValidationError if there is an invalid filter or qualification
|
||||
*/
|
||||
public ChangeResponse get(ChangeRequest request) throws ARException, NotFoundError, ValidationError {
|
||||
// api.impersonateUser("ext_StanzPa");
|
||||
|
||||
LoggerTemplates log = new LoggerTemplates(api);
|
||||
|
||||
var peopleFullName = processPeopleInfo(request);
|
||||
|
||||
|
|
@ -87,17 +93,49 @@ public class Change {
|
|||
var qualifier = filter.constructQualifier(queryChange, api);
|
||||
SortInfo sort = request.constructSortInfo(queryChange);
|
||||
|
||||
log.initLog("getChanges", api.getUser()); // Logging
|
||||
|
||||
var entries = api.queryFieldsById(qualifier, this.queryChange.getFieldIds(),
|
||||
this.queryChange.getFormName(),
|
||||
sort, request.getSliceStart(),
|
||||
request.getSliceEnd());
|
||||
|
||||
System.out.println(qualifier); // "\'1000000182\'!=\".\""
|
||||
log.qualifierLog(queryChange.getFormName(), qualifier); // Logging
|
||||
|
||||
System.out.println(qualifier);
|
||||
|
||||
var entriesSize = api.getFormSize(qualifier, this.queryChange.getFormName());
|
||||
var changes = new ArrayList<ChangeItem>();
|
||||
|
||||
for (var entry : entries) {
|
||||
var change = new ChangeItem(entry.getEntryId());
|
||||
|
||||
System.out.println();
|
||||
boolean approval = getValueStringByID(entry, "Approval").equals("0") ? true : false;
|
||||
|
||||
if (approval) {
|
||||
var queryApproval = new Query.QueryBuilder("CHG:ChangeAPDetailSignature")
|
||||
.addFieldId("ApprovalProcessName", 301322300).build();
|
||||
var queryApprovalProcessName = api.queryFieldsById(
|
||||
"(\'1000000182\' = \""
|
||||
+ getValueStringByID(entry, "ChangeNr")
|
||||
+ "\") AND (\'10000\' = \""
|
||||
+ getValueStringByID(entry, "ApprovalProcessName")
|
||||
+ "\") AND (\'13207\' LIKE \"%" + api.getUser()
|
||||
+ "%\")",
|
||||
queryApproval.getFieldIds(), queryApproval.getFormName(), sort, 0, 0);
|
||||
|
||||
System.out.println("(\'1000000182\' = \""
|
||||
+ getValueStringByID(entry, "ChangeNr")
|
||||
+ "\") AND (\'10000\' = \""
|
||||
+ getValueStringByID(entry, "ApprovalProcessName")
|
||||
+ "\") AND (\'13207\' LIKE \"%" + api.getUser()
|
||||
+ "%\")");
|
||||
System.out.println(queryApprovalProcessName.size());
|
||||
}
|
||||
|
||||
change.setApproval(approval);
|
||||
|
||||
change.setChangeNr(getValueStringByID(entry, "ChangeNr"));
|
||||
change.setSupportGroup(getValueStringByID(entry, "SupportGroup"));
|
||||
change.setState(Optional.ofNullable(getValue(entry, "State"))
|
||||
|
|
@ -124,24 +162,6 @@ public class Change {
|
|||
.map(Object::toString)
|
||||
.filter(peopleFullName::equals)
|
||||
.isPresent());
|
||||
|
||||
/*
|
||||
* var state = getValue(entry, "State").getIntValue();
|
||||
* var inApproval = inApprovalList(api.getUser(), getValueStringByID(entry,
|
||||
* "ChangeNr"));
|
||||
*
|
||||
* change.setFlagPermit(flagPermit(state));
|
||||
* change.setFlagApprove(flagApproval(inApproval, state));
|
||||
* change.setFlagReject(flagApproval(inApproval, state));
|
||||
* change.setFlagCancel(flagCancel(getValueStringByID(entry, "SupportGroupId"),
|
||||
* state));
|
||||
*/
|
||||
|
||||
// change.setFlagPermit(flagPermit(state));
|
||||
// change.setFlagApprove(flagApproval(inApproval, state));
|
||||
// change.setFlagReject(flagApproval(inApproval, state));
|
||||
// change.setFlagCancel(flagCancel(getValueStringByID(entry, "SupportGroupId"),
|
||||
// state));
|
||||
change.setPackageName(queryPackageName(getValueStringByID(entry, "PackageType").toString()));
|
||||
|
||||
var ptMinutes = getValueStringByID(entry, "PlanTimeMinutes").isEmpty() ? "00"
|
||||
|
|
@ -192,7 +212,7 @@ public class Change {
|
|||
throw new NotFoundError("No supportGroups associated to the loginId ");
|
||||
}
|
||||
// request.addFilter(
|
||||
// new FilterElement("SupportGroupId", "equals", peopleSupportGroup));
|
||||
// new FilterElement("SupportGroupId", "equals", peopleSupportGroup));
|
||||
|
||||
return peopleInfos.get(0).get(queryPerson.getFieldId("FullName")).toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public class ChangeItem {
|
|||
private Date D3;
|
||||
private Date D4;
|
||||
private double planTime;
|
||||
private boolean approval;
|
||||
// private boolean flagPermit;
|
||||
// private boolean flagApprove;
|
||||
// private boolean flagReject;
|
||||
|
|
@ -140,7 +141,7 @@ public class ChangeItem {
|
|||
public ChangeItem(String resourceId, String resourceName, String changeNr, int state, String contract,
|
||||
String supportGroup, String coordinatorSgId, String coordinatorSg, String supportGroupId,
|
||||
String providerCluster, String approvalStatus, String statusReason, Date D1, Date D2, Date D3, Date D4,
|
||||
String changeImplementer, String changeImplementerLogin, String changeImplementerPersonId) {
|
||||
String changeImplementer, String changeImplementerLogin, String changeImplementerPersonId, boolean approval) {
|
||||
this.resourceId = resourceId;
|
||||
this.resourceName = resourceName;
|
||||
this.changeNr = changeNr;
|
||||
|
|
@ -160,88 +161,16 @@ public class ChangeItem {
|
|||
this.changeImplementer = changeImplementer;
|
||||
this.changeImplementerLogin = changeImplementerLogin;
|
||||
this.changeImplementerPersonId = changeImplementerPersonId;
|
||||
this.approval = approval;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Retrieves the flag indicating whether the change item has a permit.
|
||||
// *
|
||||
// * @return {@code true} if the change item has a permit, {@code false}
|
||||
// * otherwise.
|
||||
// */
|
||||
// public boolean getFlagPermit() {
|
||||
// return this.flagPermit;
|
||||
// }
|
||||
public boolean isApproval() {
|
||||
return approval;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Sets the flag indicating whether the change item has a permit.
|
||||
// *
|
||||
// * @param flagPermit {@code true} if the change item has a permit, {@code
|
||||
// false}
|
||||
// * otherwise.
|
||||
// */
|
||||
// public void setFlagPermit(boolean flagPermit) {
|
||||
// this.flagPermit = flagPermit;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieves the flag indicating whether the change item has been approved.
|
||||
// *
|
||||
// * @return {@code true} if the change item has been approved, {@code false}
|
||||
// * otherwise.
|
||||
// */
|
||||
// public boolean getFlagApprove() {
|
||||
// return this.flagApprove;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Sets the flag indicating whether the change item has been approved.
|
||||
// *
|
||||
// * @param flagApprove {@code true} if the change item has been approved,
|
||||
// * {@code false} otherwise.
|
||||
// */
|
||||
// public void setFlagApprove(boolean flagApprove) {
|
||||
// this.flagApprove = flagApprove;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieves the flag indicating whether the change item has been rejected.
|
||||
// *
|
||||
// * @return {@code true} if the change item has been rejected, {@code false}
|
||||
// * otherwise.
|
||||
// */
|
||||
// public boolean getFlagReject() {
|
||||
// return this.flagReject;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Sets the flag indicating whether the change item has been rejected.
|
||||
// *
|
||||
// * @param flagReject {@code true} if the change item has been rejected,
|
||||
// * {@code false} otherwise.
|
||||
// */
|
||||
// public void setFlagReject(boolean flagReject) {
|
||||
// this.flagReject = flagReject;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieves the flag indicating whether the change item has been canceled.
|
||||
// *
|
||||
// * @return {@code true} if the change item has been canceled, {@code false}
|
||||
// * otherwise.
|
||||
// */
|
||||
// public boolean getFlagCancel() {
|
||||
// return this.flagCancel;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Sets the flag indicating whether the change item has been canceled.
|
||||
// *
|
||||
// * @param flagCancel {@code true} if the change item has been canceled,
|
||||
// * {@code false} otherwise.
|
||||
// */
|
||||
// public void setFlagCancel(boolean flagCancel) {
|
||||
// this.flagCancel = flagCancel;
|
||||
// }
|
||||
public void setApproval(boolean approval) {
|
||||
this.approval = approval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the planned time.
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ public class PlanTimes {
|
|||
var minutes = change.get(queryChanges.getFieldId("PlanTimeMinutes")).toString();
|
||||
var hours = change.get(queryChanges.getFieldId("PlanTimeHours")).toString();
|
||||
double plantime = convertPlanTime(hours, minutes);
|
||||
System.out.println(plantime);
|
||||
planTimePerWeek += plantime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue