public T getUniqueByProperty(String property, Object value, boolean enforceType) throws NonUniqueResultException { Iterable<T> results = findAllByProperty(property, value, enforceType); T result = null; for (WindupVertexFrame item : results) { // There can be other types using the same property name. if (!type.isInstance(item)) continue; if (result != null) { throw new NonUniqueResultException("Expected unique value, but returned non-unique: " + property + " Conflicting models:" + NL + "\t" + StringUtils.join(item.getClass().getInterfaces(), ", ") + NL + "\t\t" + item.toPrettyString() + NL + "\t" + StringUtils.join(result.getClass().getInterfaces(), ", ") + NL + "\t\t" + result.toPrettyString()); } result = (T) item; } return result; }
private void fillInNextFrame() { while(wrappedIterator.hasNext() && nextFrame==null) { T frame = wrappedIterator.next(); String frameId = frame.getElement().id().toString(); if(!ids.contains(frameId)) { ids.add(frameId); nextFrame=frame; } } }
@SuppressWarnings("unchecked") public static <T extends WindupVertexFrame> T refresh(GraphContext context, T frame) { Vertex v = context.getGraph().traversal().V((Long)frame.getId()).next(); return (T) context.getFramed().frameElement(v, WindupVertexFrame.class); }
@SuppressWarnings("unchecked") public static <T extends WindupVertexFrame> T refresh(GraphContext context, T frame) { Vertex v = context.getGraph().traversal().V((Long)frame.getId()).next(); return (T) context.getFramed().frameElement(v, WindupVertexFrame.class); }
public T getUniqueByProperty(String property, Object value, boolean enforceType) throws NonUniqueResultException { Iterable<T> results = findAllByProperty(property, value, enforceType); T result = null; for (WindupVertexFrame item : results) { // There can be other types using the same property name. if (!type.isInstance(item)) continue; if (result != null) { throw new NonUniqueResultException("Expected unique value, but returned non-unique: " + property + " Conflicting models:" + NL + "\t" + StringUtils.join(item.getClass().getInterfaces(), ", ") + NL + "\t\t" + item.toPrettyString() + NL + "\t" + StringUtils.join(result.getClass().getInterfaces(), ", ") + NL + "\t\t" + result.toPrettyString()); } result = (T) item; } return result; }
private void fillInNextFrame() { while(wrappedIterator.hasNext() && nextFrame==null) { T frame = wrappedIterator.next(); String frameId = frame.getElement().id().toString(); if(!ids.contains(frameId)) { ids.add(frameId); nextFrame=frame; } } }
/** * Returns the ReportModel with given name. */ @SuppressWarnings("unchecked") public <T extends ReportModel> T getReportByName(String name, Class<T> clazz) { WindupVertexFrame model = this.getUniqueByProperty(ReportModel.REPORT_NAME, name); try { return (T) model; } catch (ClassCastException ex) { throw new WindupException("The vertex is not of expected frame type " + clazz.getName() + ": " + model.toPrettyString()); } }
protected List<Map<String, Object>> frameIterableToResult(long executionID, Iterable<? extends WindupVertexFrame> frames, int depth) { GraphMarshallingContext ctx = new GraphMarshallingContext(executionID, null, depth, false, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), true); List<Map<String, Object>> result = new ArrayList<>(); for (WindupVertexFrame frame : frames) { result.add(convertToMap(ctx, frame.getElement())); } return result; }
/** * Returns the ReportModel with given name. */ @SuppressWarnings("unchecked") public <T extends ReportModel> T getReportByName(String name, Class<T> clazz) { WindupVertexFrame model = this.getUniqueByProperty(ReportModel.REPORT_NAME, name); try { return (T) model; } catch (ClassCastException ex) { throw new WindupException("The vertex is not of expected frame type " + clazz.getName() + ": " + model.toPrettyString()); } }
@Override public void remove(final T model) { ExecutionStatistics.performBenchmarked("GraphService.commit", () -> { model.getElement().remove(); return null; }); }
private XmlFileModel getXmlFileModelFromVertex(WindupVertexFrame vertexFrame) { final XmlFileModel xml; if (vertexFrame instanceof FileReferenceModel) { xml = (XmlFileModel) ((FileReferenceModel) vertexFrame).getFile(); } else if (vertexFrame instanceof XmlFileModel) { xml = (XmlFileModel) vertexFrame; } else { throw new WindupException("XmlFile was called on the wrong graph type ( " + vertexFrame.toPrettyString() + ")"); } return xml; }
@Override public void remove(final T model) { ExecutionStatistics.performBenchmarked("GraphService.commit", () -> { model.getElement().remove(); return null; }); }
+ System.lineSeparator()+" Old: %s" + System.lineSeparator()+" New: %s" + "%s", frame.toPrettyString(), last, frame, paramValueStoreOverwritten ? "" : System.lineSeparator()+"Further incidents will be logged at FINER level as it may occur millions of times.")); paramValueStoreOverwritten = true;
/** * Adds the specified type to this frame, and returns a new object that implements this type. */ public static <T extends WindupVertexFrame> T addTypeToModel(GraphContext graphContext, WindupVertexFrame frame, Class<T> type) { Vertex vertex = frame.getElement(); graphContext.getGraphTypeManager().addTypeToElement(type, vertex); return graphContext.getFramed().frameElement(vertex, type); }
LOG.warning(payload.toPrettyString()); return;
/** * Removes the specified type from the frame. */ public static <T extends WindupVertexFrame> WindupVertexFrame removeTypeFromModel(GraphContext graphContext, WindupVertexFrame frame, Class<T> type) { Vertex vertex = frame.getElement(); graphContext.getGraphTypeManager().removeTypeFromElement(type, vertex); return graphContext.getFramed().frameElement(vertex, WindupVertexFrame.class); }
+ System.lineSeparator()+" Old: %s" + System.lineSeparator()+" New: %s" + "%s", frame.toPrettyString(), last, frame, paramValueStoreOverwritten ? "" : System.lineSeparator()+"Further incidents will be logged at FINER level as it may occur millions of times.")); paramValueStoreOverwritten = true;
entity.getElement(), 1, false,
LOG.warning(payload.toPrettyString()); return;
/** * Adds the specified type to this frame, and returns a new object that implements this type. */ public static <T extends WindupVertexFrame> T addTypeToModel(GraphContext graphContext, WindupVertexFrame frame, Class<T> type) { Vertex vertex = frame.getElement(); graphContext.getGraphTypeManager().addTypeToElement(type, vertex); return graphContext.getFramed().frameElement(vertex, type); }