use of cern.modesti.request.RequestImpl in project modesti by jlsalmon.
the class CoreWorkflowServiceImpl method createChildRequest.
private Request createChildRequest(String requestId, Request parent, List<Point> points) {
RequestImpl request = new RequestImpl((RequestImpl) parent);
request.setRequestId(requestId);
request.setParentRequestId(parent.getRequestId());
request.setChildRequestIds(new ArrayList<>());
request.setPoints(points);
return request;
}
use of cern.modesti.request.RequestImpl in project modesti by jlsalmon.
the class RequestDifferTest method createRequest.
private Request createRequest(int numPoints, int numProperties) {
Request request = new RequestImpl();
request.setType(RequestType.UPDATE);
request.setDescription("Test description");
request.setDomain("Unit Test");
ArrayList<Point> points = new ArrayList<>();
for (int i = 1; i <= numPoints; i++) {
Point p = createPoint(i, numProperties);
points.add(p);
}
request.setPoints(points);
return request;
}
use of cern.modesti.request.RequestImpl in project modesti by jlsalmon.
the class TestUtil method getDummyRequest.
public static Request getDummyRequest() {
Request request = new RequestImpl();
request.setType(RequestType.CREATE);
request.setDescription("description");
request.setDomain("DUMMY");
request.setPoints(getDummyPoints());
return request;
}
use of cern.modesti.request.RequestImpl in project modesti by jlsalmon.
the class RequestDiffer method diff.
public static ChangeEvent diff(Request modified, Request original, String idProperty) {
List<Point> originalPointsStillPresentCurrently = deleteRemovedPoints(original.getPoints(), modified.getPoints(), idProperty);
original.setPoints(originalPointsStillPresentCurrently);
ChangeEvent event = new ChangeEvent(new DateTime(DateTimeZone.UTC));
Request modifiedClone = new RequestImpl();
Request originalClone = new RequestImpl();
ChangeVisitor visitor = new ChangeVisitor(event, modifiedClone, originalClone);
Map<Object, Point> modifiedPointMap = getPointsMap(modified.getPoints(), idProperty);
for (Point originalPoint : original.getPoints()) {
Point modifiedPoint = modifiedPointMap.get(originalPoint.getValueByPropertyName(idProperty));
originalClone.setPoints(Arrays.asList((Point[]) new Point[] { originalPoint }));
if (modifiedPoint != null) {
modifiedClone.setPoints(Arrays.asList((Point[]) new Point[] { modifiedPoint }));
}
ObjectDiffer differ = ObjectDifferBuilder.startBuilding().identity().ofCollectionItems(NodePath.with("points")).via(new PointIdentityStrategy(idProperty)).and().build();
DiffNode root = differ.compare(modifiedClone, originalClone);
if (root.hasChanges()) {
root.visit(visitor);
}
}
return event;
}
Aggregations