public static T2ReferenceImpl getAsImpl(T2Reference source) { if (source instanceof T2ReferenceImpl) { return (T2ReferenceImpl) source; } else { return new T2ReferenceImpl(source); } }
public static T2ReferenceImpl getAsImpl(T2Reference source) { if (source instanceof T2ReferenceImpl) { return (T2ReferenceImpl) source; } else { return new T2ReferenceImpl(source); } }
public static T2ReferenceImpl getAsImpl(T2Reference source) { if (source instanceof T2ReferenceImpl) { return (T2ReferenceImpl) source; } else { return new T2ReferenceImpl(source); } }
/** * 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; }
/** * 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 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 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; }
ReferenceSetDao o = (ReferenceSetDao) context .getBean("testDao"); T2ReferenceImpl id = new T2ReferenceImpl(); id.setNamespacePart("testNamespace"); id.setLocalPart("testLocal");
/** * {@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; }
ReferenceSetDao o = (ReferenceSetDao) context .getBean("testDao"); T2ReferenceImpl id = new T2ReferenceImpl(); id.setNamespacePart("testNamespace"); id.setLocalPart("testLocal");
"vanillaHibernateAppContext.xml"); ListDao o = (ListDao) context.getBean("testListDao"); T2ReferenceImpl listReference = new T2ReferenceImpl(); listReference.setContainsErrors(false); listReference.setDepth(1); T2ReferenceImpl itemId1 = new T2ReferenceImpl(); itemId1.setNamespacePart("testNamespace"); itemId1.setLocalPart("item1"); T2ReferenceImpl itemId2 = new T2ReferenceImpl(); itemId2.setNamespacePart("testNamespace"); itemId2.setLocalPart("item2"); T2ReferenceImpl listReference2 = new T2ReferenceImpl(); listReference2.setContainsErrors(false); listReference2.setDepth(1);