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; }
/** * 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"); }
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); } }
/** * 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"); }
@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"); } } }
@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"); } } }
@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"); } } }
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(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 { getHibernateTemplate().save(theDocument); } catch (Exception ex) { throw new DaoException(ex); } } else { throw new DaoException( "Supplied ErrorDocument not an instance of ErrorDocumentImpl"); } } }
@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"); } } }