/** Applies event on existing structures. If not appliable do nothing. */ public synchronized void mirror(ProgressStatusEvent event) { if (event == null) { return; } ProgressStatus effected = map.get(event.getSourceId()); ProgressStatus result = event.apply(effected); if (event instanceof ProgressStatusEventCreateChild) { map.put(((ProgressStatusEventCreateChild) event).getChildId(), result); } }
public static void readToPSEventCreateChild(ProgressStatusEventCreateChild event, JsonParser jp) throws IOException { while (jp.nextToken() != JsonToken.END_OBJECT) { String fieldname = jp.getCurrentName(); jp.nextToken(); // move to value if ("id".equals(fieldname)) { event.setChildId(jp.getText()); } else if ("allocated-steps".equals(fieldname)) { event.setAllocatedSteps(jp.getIntValue()); } else if ("total-step-count".equals(fieldname)) { event.setTotalSteps(jp.getIntValue()); } else if ("name".equals(fieldname)) { event.setName(jp.getText()); } } } }
/** Ignores allocated steps. It's mirroring implementation. */ @Override public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), 0, totalStepCount)); return result; }
@Override public synchronized ProgressStatusMirroringImpl createMirroringChild(int allocatedSteps) { allocateStapsForChildProcess(allocatedSteps); String childId = (id == null ? "" : id) + "." + (children.size() + 1); ProgressStatusMirroringImpl result = new ProgressStatusMirroringImpl(null, this, childId); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, null, result.getId(), allocatedSteps, -1)); return result; }
/** Ignores allocated steps. It's mirroring implementation. */ @Override public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), 0, totalStepCount)); return result; }
public static ProgressStatusEvent readProgressStatusEvent(JsonParser jp) throws IOException { String id = null; JsonToken token = null; ProgressStatusEvent result = null; while ((token = jp.nextToken()) != JsonToken.END_OBJECT) { if (token == JsonToken.START_OBJECT) { String nm = jp.getCurrentName(); if ("set".equals(nm)) { result = new ProgressStatusEventSet(id); readToPSEventSet((ProgressStatusEventSet) result, jp); } else if ("progres".equals(nm)) { result = new ProgressStatusEventProgress(id); readToPSEventProgress((ProgressStatusEventProgress) result, jp); } else if ("complete".equals(nm)) { result = new ProgressStatusEventComplete(id); readToPSEventComplete((ProgressStatusEventComplete) result, jp); } else if ("create-child".equals(nm)) { result = new ProgressStatusEventCreateChild(id); readToPSEventCreateChild((ProgressStatusEventCreateChild) result, jp); } } else { String fieldname = jp.getCurrentName(); if ("id".equals(fieldname)) { jp.nextToken(); // move to value id = jp.getText(); } } } return result; }
public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { if (allocatedSteps < 0) { allocatedSteps = 0; } allocateStapsForChildProcess(allocatedSteps); ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), allocatedSteps, totalStepCount)); return result; }
public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { if (allocatedSteps < 0) { allocatedSteps = 0; } allocateStapsForChildProcess(allocatedSteps); ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), allocatedSteps, totalStepCount)); return result; }