/** * Parse the reference contained in the string and return a * {@link T2Reference} with the correct properties */ public T2Reference referenceFromString(String reference) { T2ReferenceImpl newRef = new T2ReferenceImpl(); Map<String, String> parseRef = parseRef(reference); newRef.setNamespacePart(parseRef.get("namespace")); newRef.setLocalPart(parseRef.get("localPart")); String type = parseRef.get("type"); if (type.equals("ref")) { newRef.setReferenceType(T2ReferenceType.ReferenceSet); } else if (type.equals("list")) { newRef.setReferenceType(T2ReferenceType.IdentifiedList); newRef.setContainsErrors(Boolean .parseBoolean(parseRef.get("error"))); newRef.setDepth(Integer.parseInt(parseRef.get("depth"))); } else if (type.equals("error")) { newRef.setContainsErrors(true); newRef.setReferenceType(T2ReferenceType.ErrorDocument); newRef.setDepth(Integer.parseInt(parseRef.get("depth"))); } else { return null; // should throw an error } return newRef; }
/** * Parse the reference contained in the string and return a * {@link T2Reference} with the correct properties */ public T2Reference referenceFromString(String reference) { T2ReferenceImpl newRef = new T2ReferenceImpl(); Map<String, String> parseRef = parseRef(reference); newRef.setNamespacePart(parseRef.get("namespace")); newRef.setLocalPart(parseRef.get("localPart")); String type = parseRef.get("type"); if (type.equals("ref")) { newRef.setReferenceType(T2ReferenceType.ReferenceSet); } else if (type.equals("list")) { newRef.setReferenceType(T2ReferenceType.IdentifiedList); newRef.setContainsErrors(Boolean .parseBoolean(parseRef.get("error"))); newRef.setDepth(Integer.parseInt(parseRef.get("depth"))); } else if (type.equals("error")) { newRef.setContainsErrors(true); newRef.setReferenceType(T2ReferenceType.ErrorDocument); newRef.setDepth(Integer.parseInt(parseRef.get("depth"))); } else { return null; // should throw an error } return newRef; }
/** * {@inheritDoc} */ public synchronized T2Reference nextReferenceSetReference() { T2ReferenceImpl r = new T2ReferenceImpl(); r.setNamespacePart(getNamespace()); r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.ReferenceSet); r.setDepth(0); r.setContainsErrors(false); return r; }
/** * {@inheritDoc} */ public T2Reference nextErrorDocumentReference(int depth) { T2ReferenceImpl r = new T2ReferenceImpl(); r.setNamespacePart(getNamespace()); r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.ErrorDocument); r.setDepth(depth); // This is an error document, it contains errors by definition r.setContainsErrors(true); return r; }
/** * {@inheritDoc} */ public T2Reference nextErrorDocumentReference(int depth) { T2ReferenceImpl r = new T2ReferenceImpl(); r.setNamespacePart(getNamespace()); r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.ErrorDocument); r.setDepth(depth); // This is an error document, it contains errors by definition r.setContainsErrors(true); return r; }
/** * Drill inside an error document reference to get the error one deeper than * this as long as it is at least depth 1. */ T2ReferenceImpl getDeeperErrorReference() { if (getReferenceType().equals(T2ReferenceType.ErrorDocument)) { if (getDepth() == 0) { throw new AssertionError("Error identifier already has depth 0, cannot decrease"); } T2ReferenceImpl result = new T2ReferenceImpl(); result.setContainsErrors(true); result.setDepth(getDepth() - 1); result.setLocalPart(getLocalPart()); result.setNamespacePart(getNamespacePart()); result.setReferenceType(T2ReferenceType.ErrorDocument); return result; } throw new AssertionError( "Attempt to get a deeper reference on something that isn't an error ref"); }
/** * {@inheritDoc} */ public T2Reference nextListReference(boolean containsErrors, int listDepth) { T2ReferenceImpl r = new T2ReferenceImpl(); r.setNamespacePart(getNamespace()); r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.IdentifiedList); r.setDepth(listDepth); r.setContainsErrors(containsErrors); return r; }
/** * {@inheritDoc} */ public synchronized T2Reference nextReferenceSetReference() { T2ReferenceImpl r = new T2ReferenceImpl(); r.setNamespacePart(getNamespace()); r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.ReferenceSet); r.setDepth(0); r.setContainsErrors(false); return r; }
/** * {@inheritDoc} */ public T2Reference nextListReference(boolean containsErrors, int listDepth) { T2ReferenceImpl r = new T2ReferenceImpl(); r.setNamespacePart(getNamespace()); r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.IdentifiedList); r.setDepth(listDepth); r.setContainsErrors(containsErrors); return r; }
/** * Drill inside an error document reference to get the error one deeper than * this as long as it is at least depth 1. */ T2ReferenceImpl getDeeperErrorReference() { if (getReferenceType().equals(T2ReferenceType.ErrorDocument)) { if (getDepth() == 0) { throw new AssertionError( "Error identifier already has depth 0, cannot decrease"); } T2ReferenceImpl result = new T2ReferenceImpl(); result.setContainsErrors(true); result.setDepth(getDepth() - 1); result.setLocalPart(getLocalPart()); result.setNamespacePart(getNamespacePart()); result.setReferenceType(T2ReferenceType.ErrorDocument); return result; } throw new AssertionError( "Attempt to get a deeper reference on something that isn't an error ref"); }
/** * Drill inside an error document reference to get the error one deeper than * this as long as it is at least depth 1. */ T2ReferenceImpl getDeeperErrorReference() { if (getReferenceType().equals(T2ReferenceType.ErrorDocument)) { if (getDepth() == 0) { throw new AssertionError( "Error identifier already has depth 0, cannot decrease"); } T2ReferenceImpl result = new T2ReferenceImpl(); result.setContainsErrors(true); result.setDepth(getDepth() - 1); result.setLocalPart(getLocalPart()); result.setNamespacePart(getNamespacePart()); result.setReferenceType(T2ReferenceType.ErrorDocument); return result; } throw new AssertionError( "Attempt to get a deeper reference on something that isn't an error ref"); }
/** * {@inheritDoc} */ public T2Reference nextListReference(boolean containsErrors, int listDepth, ReferenceContext context) { T2ReferenceImpl r = new T2ReferenceImpl(); if (context == null){ r.setNamespacePart(getNamespace()); // this is not good, just use the default namespace } else { List<WorkflowRunIdEntity> workflowRunIdEntities = context.getEntities(WorkflowRunIdEntity.class); if (workflowRunIdEntities == null || workflowRunIdEntities.isEmpty()){ // this is not good, just use the default namespace r.setNamespacePart(getNamespace()); } else { // there should be only one wf run id entity String workflowRunId = ((WorkflowRunIdEntity)workflowRunIdEntities.get(0)).getWorkflowRunId(); r.setNamespacePart(workflowRunId); } } r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.IdentifiedList); r.setDepth(listDepth); r.setContainsErrors(containsErrors); return r; }
/** * {@inheritDoc} */ public T2Reference nextErrorDocumentReference(int depth, ReferenceContext context) { T2ReferenceImpl r = new T2ReferenceImpl(); if (context == null){ r.setNamespacePart(getNamespace()); // this is not good, just use the default namespace } else { List<WorkflowRunIdEntity> workflowRunIdEntities = context.getEntities(WorkflowRunIdEntity.class); if (workflowRunIdEntities == null || workflowRunIdEntities.isEmpty()){ // this is not good, just use the default namespace r.setNamespacePart(getNamespace()); } else { // there should be only one wf run id entity String workflowRunId = ((WorkflowRunIdEntity)workflowRunIdEntities.get(0)).getWorkflowRunId(); r.setNamespacePart(workflowRunId); } } r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.ErrorDocument); r.setDepth(depth); // This is an error document, it contains errors by definition r.setContainsErrors(true); return r; }
/** * Construct a deep copy of the given T2Reference * * @param source * T2Reference to copy */ private T2ReferenceImpl(T2Reference source) { super(); setNamespacePart(source.getNamespacePart()); setLocalPart(source.getLocalPart()); setContainsErrors(source.containsErrors()); setReferenceType(source.getReferenceType()); setDepth(source.getDepth()); }
/** * {@inheritDoc} */ public synchronized T2Reference nextReferenceSetReference(ReferenceContext context) { T2ReferenceImpl r = new T2ReferenceImpl(); if (context == null){ r.setNamespacePart(getNamespace()); // this is not good, just use the default namespace } else { List<WorkflowRunIdEntity> workflowRunIdEntities = context.getEntities(WorkflowRunIdEntity.class); if (workflowRunIdEntities == null || workflowRunIdEntities.isEmpty()){ // this is not good, just use the default namespace r.setNamespacePart(getNamespace()); } else { // there should be only one wf run id entity String workflowRunId = ((WorkflowRunIdEntity)workflowRunIdEntities.get(0)).getWorkflowRunId(); r.setNamespacePart(workflowRunId); } } r.setLocalPart(getNextLocalPart()); r.setReferenceType(T2ReferenceType.ReferenceSet); r.setDepth(0); r.setContainsErrors(false); return r; }
/** * Construct a deep copy of the given T2Reference * * @param source * T2Reference to copy */ private T2ReferenceImpl(T2Reference source) { super(); setNamespacePart(source.getNamespacePart()); setLocalPart(source.getLocalPart()); setContainsErrors(source.containsErrors()); setReferenceType(source.getReferenceType()); setDepth(source.getDepth()); }
/** * Construct a deep copy of the given T2Reference * * @param source * T2Reference to copy */ private T2ReferenceImpl(T2Reference source) { super(); setNamespacePart(source.getNamespacePart()); setLocalPart(source.getLocalPart()); setContainsErrors(source.containsErrors()); setReferenceType(source.getReferenceType()); setDepth(source.getDepth()); }
listReference.setLocalPart("list1"); listReference.setNamespacePart("testNamespace"); listReference.setReferenceType(T2ReferenceType.IdentifiedList); listReference2.setLocalPart("list1"); listReference2.setNamespacePart("testNamespace"); listReference2.setReferenceType(T2ReferenceType.IdentifiedList);
listReference.setLocalPart("list1"); listReference.setNamespacePart("testNamespace"); listReference.setReferenceType(T2ReferenceType.IdentifiedList); listReference2.setLocalPart("list1"); listReference2.setNamespacePart("testNamespace"); listReference2.setReferenceType(T2ReferenceType.IdentifiedList);