@Override protected PersisterContext initialValue() { return new PersisterContext(); } };
public PersisterUnexpectedException(String message, Throwable cause) { super(message, cause); PersisterContext.getInstance().clear(); } }
public boolean isDryRun() { return PersisterContext.getInstance().isDryRun(); }
/** * Mandatory method to execute the actual data persister in the database. */ public final void commit() { PersisterContext.getInstance().persistAll(); }
public void persistAll() { if (log.isDebugEnabled()) { log.debug("Persisting all"+ (isDryRun()? " - DRY RUN" : "")); log.debug("\tCvObjects: "+cvObjectsToBePersisted.size()); for ( String key : cvObjectsToBePersisted.keySet() ) { getDaoFactory().getInstitutionDao().replicate(institution); } else { if ( log.isDebugEnabled() ) { log.debug( "\t\tPersisting " + institution.getClass().getSimpleName() + ": " + institution.getShortLabel() ); getDaoFactory().getInstitutionDao().persist(institution); getDaoFactory().getCvObjectDao().merge(cv); } else { if ( log.isDebugEnabled() ) { log.debug( "\t\tPersisting " + cv.getClass().getSimpleName() + ": " + cv.getShortLabel() ); getDaoFactory().getCvObjectDao().persist(cv); logPersistence(cv); getIntactContext().getDataContext().flushSession(); getDaoFactory().getAnnotatedObjectDao((Class<AnnotatedObject>)ao.getClass()).persist(ao); logPersistence(ao); getIntactContext().getDataContext().flushSession();
if (PersisterContext.getInstance().contains(intactObject)) { if ( log.isDebugEnabled() ) { log.debug( intactObject.getClass().getSimpleName() + ": " + intactObject.getShortLabel() + "("+ AnnotKeyGenerator.createKey(intactObject)+") is already in the PersisterContext, skipping..." ); getIntactContext().getDataContext().getDaoFactory().getIntactObjectDao().evict(objectToUpdate); PersisterContext.getInstance().addToUpdate(objectToUpdate); PersisterContext.getInstance().addToPersist(newAnnotatedObject);
if (PersisterContext.getInstance().contains(intactObject)) { if ( log.isDebugEnabled() ) log.debug( "\t\t\tFound it in PersisterContext" ); T current = (T) PersisterContext.getInstance().get(intactObject);
@Override public Institution syncIfTransient(Institution intactObject) { if (PersisterContext.getInstance().contains(intactObject)) { return intactObject; PersisterContext.getInstance().addToPersist(intactObject);
public static EntryPersister getInstance(boolean isDryRun) { PersisterContext.getInstance().setDryRun(isDryRun); return instance.get(); }
public void addToPersist(Institution institution) { if ( !contains( institution ) ) { institutionsToBePersisted.put( institution.getShortLabel(), institution ); } }
private DaoFactory getDaoFactory() { return getIntactContext().getDataContext().getDaoFactory(); }
public void commit() { PersisterContext.getInstance().persistAll(); } }
public PersisterException(String message) { super(message); PersisterContext.getInstance().clear(); }
public static void saveOrUpdate(IntactObject ... intactObjects) throws PersisterException { boolean inTransaction = IntactContext.getCurrentInstance().getDataContext().isTransactionActive(); if (!inTransaction) IntactContext.getCurrentInstance().getDataContext().beginTransaction(); for (IntactObject intactObject : intactObjects) { Persister persister = persisterFor(intactObject.getClass()); persister.saveOrUpdate(intactObject); } PersisterContext.getInstance().persistAll(); if (!inTransaction) commitTransactionAndRollbackIfNecessary(); }
public PersisterException(String message, Throwable cause) { super(message, cause); PersisterContext.getInstance().clear(); } }
public PersisterUnexpectedException(String message) { super(message); PersisterContext.getInstance().clear(); }
public PersisterException(Throwable cause) { super(cause); PersisterContext.getInstance().clear(); }
public PersisterUnexpectedException(Throwable cause) { super(cause); PersisterContext.getInstance().clear(); }
public PersisterException() { PersisterContext.getInstance().clear(); }
public PersisterUnexpectedException() { PersisterContext.getInstance().clear(); }