
com.centurylink.mdw.model.request.Request Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mdw-common Show documentation
Show all versions of mdw-common Show documentation
MDW is a microservices based workflow framework
/*
* Copyright (C) 2017 CenturyLink, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.centurylink.mdw.model.request;
import com.centurylink.mdw.model.Jsonable;
import com.centurylink.mdw.model.Response;
import com.centurylink.mdw.util.DateHelper;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Date;
public class Request implements Jsonable {
public static final String REQUEST_ID = "request-id";
// this is the document id
private Long id = 0L;
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
private Date created;
public Date getCreated() { return created; }
public void setCreated(Date received) { this.created = received; }
private Date responded;
public Date getResponded() { return responded; }
public void setResponded(Date responded) { this.responded = responded; }
private Long responseId;
public Long getResponseId() { return responseId; }
public void setResponseId(Long responseId) { this.responseId = responseId; }
private Long responseMs;
public Long getResponseMs() { return responseMs; }
public void setResponseMs(Long ms) { this.responseMs = ms; }
private String masterRequestId;
public String getMasterRequestId() { return masterRequestId; }
public void setMasterRequestId(String masterRequestId) { this.masterRequestId = masterRequestId; }
private Long processInstanceId;
public Long getProcessInstanceId() { return processInstanceId; }
public void setProcessInstanceId(Long instanceId) { this.processInstanceId = instanceId; }
private Long activityInstanceId;
public Long getActivityInstanceId() { return activityInstanceId; }
public void setActivityInstanceId(Long instanceId) { this.activityInstanceId = instanceId; }
private Long processId;
public Long getProcessId() { return processId; }
public void setProcessId(Long id) { this.processId = id; }
private String processName;
public String getProcessName() { return processName; }
public void setProcessName(String processName) { this.processName = processName; }
private String processVersion;
public String getProcessVersion() { return processVersion; }
public void setProcessVersion(String version) { this.processVersion = version; }
private String packageName;
public String getPackageName() { return packageName; }
public void setPackageName(String pkg) { this.packageName = pkg; }
private String processStatus;
public String getProcessStatus() { return processStatus; }
public void setProcessStatus(String status) { this.processStatus = status; }
private Date processStart;
public Date getProcessStart() { return processStart; }
public void setProcessStart(Date start) { this.processStart = start; }
private Date processEnd;
public Date getProcessEnd() { return processEnd; }
public void setProcessEnd(Date end) { this.processEnd = end; }
private String content;
public String getContent() { return content; }
public void setContent(String c) { this.content = c; }
public String getResponseContent() { return response == null ? null : response.getContent(); }
private boolean outbound;
public boolean isOutbound() { return outbound; }
public void setOutbound(boolean ob) { this.outbound = ob; }
private Integer statusCode;
public Integer getStatusCode() { return statusCode; }
public void setStatusCode(Integer code) { this.statusCode = code; }
private String statusMessage;
public String getStatusMessage() { return statusMessage; }
public void setStatusMessage(String message) { this.statusMessage = message; }
private String path;
public String getPath() { return path; }
public void setPath(String path) { this.path = path; }
private JSONObject meta;
public JSONObject getMeta() { return meta; }
public void setMeta(JSONObject info) { meta = info; }
private Long metaId;
public Long getMetaId() { return metaId; }
public void setMetaId(Long id) { this.metaId = id; }
private Response response;
public Response getResponse() { return response; }
public void setResponse(Response resp) { response = resp; }
public Request(Long id) {
this.id = id;
}
public Request(String content) {
this.content = content;
}
public Request(JSONObject json) throws JSONException {
if (json.has("id"))
id = json.getLong("id");
if (json.has("created"))
created = DateHelper.stringToDate(json.getString("created"));
if (json.has("responded"))
responded = DateHelper.stringToDate(json.getString("responded"));
if (json.has("responseId"))
responseId = json.getLong("responseId");
if (json.has("masterRequestId"))
masterRequestId = json.getString("masterRequestId");
if (json.has("processInstanceId"))
processInstanceId = json.getLong("processInstanceId");
if (json.has("activityInstanceId"))
activityInstanceId = json.getLong("activityInstanceId");
if (json.has("processId"))
processId = json.getLong("processId");
if (json.has("processName"))
processName = json.getString("processName");
if (json.has("processVersion"))
processVersion = json.getString("processVersion");
if (json.has("packageName"))
packageName = json.getString("packageName");
if (json.has("processStatus"))
processStatus = json.getString("processStatus");
if (json.has("processStart"))
processStart = DateHelper.stringToDate(json.getString("processStart"));
if (json.has("processEnd"))
processEnd = DateHelper.stringToDate(json.getString("processEnd"));
if (json.has("outbound"))
outbound = json.getBoolean("outbound");
if (json.has("content"))
content = json.getString("content");
if (json.has("responseContent"))
response = new Response(json.getString("responseContent"));
if (json.has("statusCode"))
statusCode = json.getInt("statusCode");
if (json.has("statusMessage"))
statusMessage = json.getString("statusMessage");
if (json.has("path"))
path = json.getString("path");
if (json.has("responseMs"))
responseMs = json.getLong("responseMs");
}
public JSONObject getJson() throws JSONException {
JSONObject json = create();
if (id > 0)
json.put("id", id);
if (created != null)
json.put("created", DateHelper.dateToString(created));
if (responded != null)
json.put("responded", DateHelper.dateToString(responded));
if (responseId != null)
json.put("responseId", responseId);
if (masterRequestId != null)
json.put("masterRequestId", masterRequestId);
if (processInstanceId != null)
json.put("processInstanceId", processInstanceId);
if (activityInstanceId != null)
json.put("activityInstanceId", activityInstanceId);
if (processId != null)
json.put("processId", processId);
if (processName != null)
json.put("processName", processName);
if (processVersion != null)
json.put("processVersion", processVersion);
if (packageName != null)
json.put("packageName", packageName);
if (processStatus != null)
json.put("processStatus", processStatus);
if (processStart != null)
json.put("processStart", DateHelper.dateToString(processStart));
if (processEnd != null)
json.put("processEnd", DateHelper.dateToString(processEnd));
if (outbound)
json.put("outbound", outbound);
if (content != null)
json.put("content", content);
if (meta != null)
json.put("meta", meta);
if (response != null && response.getContent() != null)
json.put("responseContent", response.getContent());
if (response != null && response.getMeta() != null)
json.put("responseMeta", response.getMeta());
if (statusCode != null)
json.put("statusCode", statusCode);
if (statusMessage != null)
json.put("statusMessage", statusMessage);
if (path != null)
json.put("path", path);
if (responseMs != null) {
json.put("responseMs", responseMs);
}
return json;
}
public String getJsonName() {
return "request";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy