Skip to content

Commit

Permalink
added helper newX methods, cleanup
Browse files Browse the repository at this point in the history
added helper newX methods, cleanup
  • Loading branch information
amavashev committed Jul 23, 2019
1 parent 3875fe8 commit 9d976fd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/jkoolcloud/client/api/model/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public String getMsgTag() {
return msgTag;
}

public Trackable setMsgTag(String msgTag) {
public Event setMsgTag(String msgTag) {
this.msgTag = msgTag;
return this;
}
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/com/jkoolcloud/client/api/service/JKStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.jkoolcloud.client.api.model.Dataset;
import com.jkoolcloud.client.api.model.Event;
import com.jkoolcloud.client.api.model.Snapshot;
import com.jkoolcloud.client.api.model.Trackable;

Expand Down Expand Up @@ -93,4 +95,50 @@ public Response post(Snapshot snapshot) throws JKStreamException {
return target.path(JK_SNAPSHOT_KEY).request().header(TOKEN_KEY, token)
.post(Entity.entity(serialize(snapshot), MediaType.APPLICATION_JSON));
}

/**
* Create a new {@link Event}
*
* @return {@link Event}
*/
public static Event newEvent() {
return new Event();
}

/**
* Create a new {@link Event}
*
* @param name
* event name
* @return {@link Event}
*/
public static Event newEvent(String name) {
return new Event(name);
}

/**
* Create a new {@link Snapshot}
*
* @param cat
* category name
* @param name
* snapshot name
* @return {@link Snapshot}
*/
public static Snapshot newSnapshot(String cat, String name) {
return new Snapshot(cat, name);
}

/**
* Create a new {@link Dataset}
*
* @param cat
* category name
* @param name
* dataset name
* @return {@link Dataset}
*/
public static Dataset newDataset(String cat, String name) {
return new Dataset(cat, name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.jkoolcloud.client.api.model.Event;
import com.jkoolcloud.client.api.model.EventTypes;
import com.jkoolcloud.client.api.model.Severities;
import com.jkoolcloud.client.api.model.Trackable;
import com.jkoolcloud.client.api.service.JKStream;

/**************************************************************************************************************************
Expand Down Expand Up @@ -52,8 +53,7 @@ public static void main(String[] args) {
// representing a message received in a
// hypothetical
// messaging queue residing in New York.
Event event = new Event("ReceiveOrder");
event.setMsgText("OrderId=28372373 received.").setSourceUrl("https://www.sample.com/orders/parts")
Trackable event = JKStream.newEvent("ReceiveOrder").setMsgText("OrderId=28372373 received.").setSourceUrl("https://www.sample.com/orders/parts")
.setSeverity(Severities.INFO).setType(EventTypes.RECEIVE).setTid(Thread.currentThread().getId())
.setCompCode(CompCodes.SUCCESS).setLocation("New York, NY").setUser("webuser")
.setElapsedTimeUsec(3500).setCorrId(Arrays.asList("CorrId:123")).setResource("ORDERS.QUEUE")
Expand All @@ -72,8 +72,7 @@ public static void main(String[] args) {
// messaging queue residing in New York to a hypothetical messaging
// queue residing in Los Angeles
// (RestSample2 class)
event = new Event("ProcessOrder");
event.setMsgText("Order Processed ProductId=28372373").setSeverity(Severities.INFO).setType(EventTypes.SEND)
event = JKStream.newEvent("ProcessOrder").setMsgText("Order Processed ProductId=28372373").setSeverity(Severities.INFO).setType(EventTypes.SEND)
.setTid(Thread.currentThread().getId()).setCompCode(CompCodes.SUCCESS).setReasonCode(0)
.setLocation("New York, NY").setUser("webuser").setElapsedTimeUsec(0)
.setCorrId(Arrays.asList("CorrId:123")).setResource("PAYMENT.QUEUE").setAppl("WebOrders")
Expand Down

0 comments on commit 9d976fd

Please sign in to comment.