private Set<T2Reference> getErrors(T2Reference ref) { Set<T2Reference> result = new HashSet<T2Reference>(); if (ref.getReferenceType().equals(ReferenceSet)) { // nothing } else if (ref.getReferenceType().equals(IdentifiedList)) { IdentifiedList<T2Reference> originalList = listService.getList(ref); for (T2Reference subValue : originalList) if (subValue.containsErrors()) result.addAll(getErrors(subValue)); } else { result.add(ref); } return result; }
private T2Reference findFirstFailure(T2Reference value) { IdentifiedList<T2Reference> originalList = listService.getList(value); for (T2Reference subValue : originalList) { if (subValue.getReferenceType().equals(ErrorDocument)) return subValue; if (subValue.getReferenceType().equals(IdentifiedList)) if (subValue.containsErrors()) return findFirstFailure(subValue); // No need to consider value } return null; }
public static List<ErrorDocument> getErrorDocuments(T2Reference reference, InvocationContext context) { List<ErrorDocument> errorDocuments = new ArrayList<ErrorDocument>(); if (reference.getReferenceType().equals(T2ReferenceType.ErrorDocument)) { ErrorDocumentService errorDocumentService = context.getReferenceService().getErrorDocumentService(); errorDocuments.add(errorDocumentService.getError(reference)); } else if (reference.getReferenceType().equals(T2ReferenceType.IdentifiedList)) { ListService listService = context.getReferenceService().getListService(); IdentifiedList<T2Reference> list = listService.getList(reference); for (T2Reference listReference : list) { errorDocuments.addAll(getErrorDocuments(listReference, context)); } } return errorDocuments; }
public static List<ErrorDocument> getErrorDocuments(T2Reference reference, ReferenceService referenceService) { List<ErrorDocument> errorDocuments = new ArrayList<ErrorDocument>(); if (reference.getReferenceType().equals(T2ReferenceType.ErrorDocument)) { ErrorDocumentService errorDocumentService = referenceService .getErrorDocumentService(); errorDocuments.add(errorDocumentService.getError(reference)); } else if (reference.getReferenceType().equals( T2ReferenceType.IdentifiedList)) { ListService listService = referenceService.getListService(); IdentifiedList<T2Reference> list = listService.getList(reference); for (T2Reference listReference : list) { errorDocuments .addAll(getErrorDocuments(listReference, referenceService)); } } return errorDocuments; }
public static List<ErrorDocument> getErrorDocuments(T2Reference reference, ReferenceService referenceService) { List<ErrorDocument> errorDocuments = new ArrayList<ErrorDocument>(); if (reference.getReferenceType().equals(T2ReferenceType.ErrorDocument)) { ErrorDocumentService errorDocumentService = referenceService .getErrorDocumentService(); errorDocuments.add(errorDocumentService.getError(reference)); } else if (reference.getReferenceType().equals( T2ReferenceType.IdentifiedList)) { ListService listService = referenceService.getListService(); IdentifiedList<T2Reference> list = listService.getList(reference); for (T2Reference listReference : list) { errorDocuments .addAll(getErrorDocuments(listReference, referenceService)); } } return errorDocuments; }
public boolean delete(T2Reference reference) throws ReferenceServiceException { boolean result=false; switch (reference.getReferenceType()) { case IdentifiedList: result=listService.delete(reference); break; case ReferenceSet: result=referenceSetService.delete(reference); break; case ErrorDocument: result=errorDocumentService.delete(reference); break; default: throw new ReferenceServiceException( "Unknown reference type!"); } return result; }
private void createTree(T2Reference t2Ref, ProcessorResultTreeNode parentNode){ // If reference contains a list of data references if (t2Ref.getReferenceType() == T2ReferenceType.IdentifiedList) { IdentifiedList<T2Reference> list = referenceService .getListService().getList(t2Ref); if (list == null) { logger.error("Could not resolve list " + t2Ref + ", was run with in-memory storage?"); } ProcessorResultTreeNode listNode = new ProcessorResultTreeNode(list.size(), t2Ref, referenceService); // list node parentNode.add(listNode); for (T2Reference ref : list) { createTree(ref, listNode); } } else { // reference to single data or an error insertDataNode(t2Ref, parentNode); } }
public boolean delete( IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { sessionFactory.getCurrentSession().delete(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } return true; }
private T2Reference considerReference(T2Reference value, List<T2Reference> exceptions) { if (!value.containsErrors()) { return value; } else if (!value.getReferenceType().equals(IdentifiedList)) { return replaceErrors(value, exceptions); } else if (exceptionHandling.failLists()) { T2Reference failure = findFirstFailure(value); T2Reference replacement = replaceErrors(failure, value.getDepth(), exceptions); return replacement; } else { IdentifiedList<T2Reference> originalList = listService .getList(value); List<T2Reference> replacementList = new ArrayList<T2Reference>(); for (T2Reference subValue : originalList) replacementList.add(considerReference(subValue, exceptions)); return referenceService.register(replacementList, value.getDepth(), true, context); } }
@PutIdentifiedOperation public void store(IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { sessionFactory.getCurrentSession().save(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } }
@PutIdentifiedOperation public void store(IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { sessionFactory.getCurrentSession().save(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } } }
@PutIdentifiedOperation public void store(IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { sessionFactory.getCurrentSession().save(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } } }
@PutIdentifiedOperation public void store(ErrorDocument theDocument) throws DaoException { if (theDocument.getId() == null) { throw new DaoException( "Supplied error document set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theDocument.getId().getReferenceType().equals( T2ReferenceType.ErrorDocument) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.ErrorDocument, something has probably " + "gone badly wrong somewhere earlier!"); } if (theDocument instanceof ErrorDocumentImpl) { try { sessionFactory.getCurrentSession().save(theDocument); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied ErrorDocument not an instance of ErrorDocumentImpl"); } } }
/** * 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()); }
/** * 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()); }
public boolean delete( IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { getHibernateTemplate().delete(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } return true; }
@PutIdentifiedOperation public void store(IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { getHibernateTemplate().save(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } }
@PutIdentifiedOperation public void store(IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { getHibernateTemplate().save(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } } }
@PutIdentifiedOperation public void store(IdentifiedList<T2Reference> theList) throws DaoException { if (theList.getId() == null) { throw new DaoException("Supplied list set has a null ID, allocate " + "an ID before calling the store method in the dao."); } else if (theList.getId().getReferenceType().equals( T2ReferenceType.IdentifiedList) == false) { throw new DaoException("Strangely the list ID doesn't have type " + "T2ReferenceType.IdentifiedList, something has probably " + "gone badly wrong somewhere earlier!"); } if (theList instanceof T2ReferenceListImpl) { try { getHibernateTemplate().save(theList); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied identifier list not an instance of T2ReferenceList"); } } }