Skip to content

Commit 9d976fd

Browse files
committed
added helper newX methods, cleanup
added helper newX methods, cleanup
1 parent 3875fe8 commit 9d976fd

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

src/main/java/com/jkoolcloud/client/api/model/Event.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public String getMsgTag() {
141141
return msgTag;
142142
}
143143

144-
public Trackable setMsgTag(String msgTag) {
144+
public Event setMsgTag(String msgTag) {
145145
this.msgTag = msgTag;
146146
return this;
147147
}

src/main/java/com/jkoolcloud/client/api/service/JKStream.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import javax.ws.rs.core.MediaType;
2020
import javax.ws.rs.core.Response;
2121

22+
import com.jkoolcloud.client.api.model.Dataset;
23+
import com.jkoolcloud.client.api.model.Event;
2224
import com.jkoolcloud.client.api.model.Snapshot;
2325
import com.jkoolcloud.client.api.model.Trackable;
2426

@@ -93,4 +95,50 @@ public Response post(Snapshot snapshot) throws JKStreamException {
9395
return target.path(JK_SNAPSHOT_KEY).request().header(TOKEN_KEY, token)
9496
.post(Entity.entity(serialize(snapshot), MediaType.APPLICATION_JSON));
9597
}
98+
99+
/**
100+
* Create a new {@link Event}
101+
*
102+
* @return {@link Event}
103+
*/
104+
public static Event newEvent() {
105+
return new Event();
106+
}
107+
108+
/**
109+
* Create a new {@link Event}
110+
*
111+
* @param name
112+
* event name
113+
* @return {@link Event}
114+
*/
115+
public static Event newEvent(String name) {
116+
return new Event(name);
117+
}
118+
119+
/**
120+
* Create a new {@link Snapshot}
121+
*
122+
* @param cat
123+
* category name
124+
* @param name
125+
* snapshot name
126+
* @return {@link Snapshot}
127+
*/
128+
public static Snapshot newSnapshot(String cat, String name) {
129+
return new Snapshot(cat, name);
130+
}
131+
132+
/**
133+
* Create a new {@link Dataset}
134+
*
135+
* @param cat
136+
* category name
137+
* @param name
138+
* dataset name
139+
* @return {@link Dataset}
140+
*/
141+
public static Dataset newDataset(String cat, String name) {
142+
return new Dataset(cat, name);
143+
}
96144
}

src/main/java/com/jkoolcloud/client/samples/messaging/RestSample1.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.jkoolcloud.client.api.model.Event;
2626
import com.jkoolcloud.client.api.model.EventTypes;
2727
import com.jkoolcloud.client.api.model.Severities;
28+
import com.jkoolcloud.client.api.model.Trackable;
2829
import com.jkoolcloud.client.api.service.JKStream;
2930

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

0 commit comments

Comments
 (0)