Search in sources :

Example 1 with RequestImpl

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;
}
Also used : RequestImpl(cern.modesti.request.RequestImpl)

Example 2 with RequestImpl

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;
}
Also used : Request(cern.modesti.request.Request) ArrayList(java.util.ArrayList) Point(cern.modesti.point.Point) RequestImpl(cern.modesti.request.RequestImpl) Point(cern.modesti.point.Point)

Example 3 with RequestImpl

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;
}
Also used : Request(cern.modesti.request.Request) RequestImpl(cern.modesti.request.RequestImpl)

Example 4 with RequestImpl

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;
}
Also used : Request(cern.modesti.request.Request) DiffNode(de.danielbechler.diff.node.DiffNode) Point(cern.modesti.point.Point) DateTime(org.joda.time.DateTime) RequestImpl(cern.modesti.request.RequestImpl) ObjectDiffer(de.danielbechler.diff.ObjectDiffer)

Aggregations

RequestImpl (cern.modesti.request.RequestImpl)4 Request (cern.modesti.request.Request)3 Point (cern.modesti.point.Point)2 ObjectDiffer (de.danielbechler.diff.ObjectDiffer)1 DiffNode (de.danielbechler.diff.node.DiffNode)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1