public static String intactObjectToString(IntactObject io, boolean showAttributesCount) { if (io instanceof AnnotatedObject) { return annotatedObjectToString((AnnotatedObject) io, showAttributesCount); } Class clazz = CgLibUtil.removeCglibEnhanced(io.getClass()); StringBuilder sb = new StringBuilder(); sb.append(clazz.getSimpleName()).append(", ac=").append(io.getAc()).append("}"); return sb.toString(); } }
public static String intactObjectToString(IntactObject io, boolean showAttributesCount) { if (io instanceof AnnotatedObject) { return annotatedObjectToString((AnnotatedObject) io, showAttributesCount); } Class clazz = CgLibUtil.removeCglibEnhanced(io.getClass()); StringBuilder sb = new StringBuilder(); sb.append(clazz.getSimpleName()).append(", ac=").append(io.getAc()).append("}"); return sb.toString(); } }
sourceInfo = DebugUtil.annotatedObjectToString((AnnotatedObject) source, true);
sourceInfo = DebugUtil.annotatedObjectToString((AnnotatedObject) source, true);
@Transactional @IntactFlushMode(FlushModeType.COMMIT) public PersisterStatistics saveOrUpdate( AnnotatedObject... annotatedObjects ) throws PersisterException { for (AnnotatedObject ao : annotatedObjects) { if (log.isDebugEnabled()) log.debug("Saving: "+DebugUtil.annotatedObjectToString(ao, false)); synchronize(ao); } commit(); // we reload the annotated objects by its AC // note: if an object does not have one, it is probably a duplicate for ( AnnotatedObject ao : annotatedObjects ) { reload( ao ); } if (log.isDebugEnabled()) log.debug(statistics); return statistics; }
@Transactional @IntactFlushMode(FlushModeType.COMMIT) public PersisterStatistics saveOrUpdate( AnnotatedObject... annotatedObjects ) throws PersisterException { for (AnnotatedObject ao : annotatedObjects) { if (log.isDebugEnabled()) log.debug("Saving: "+DebugUtil.annotatedObjectToString(ao, false)); synchronize(ao); } commit(); // we reload the annotated objects by its AC // note: if an object does not have one, it is probably a duplicate for ( AnnotatedObject ao : annotatedObjects ) { reload( ao ); } if (log.isDebugEnabled()) log.debug(statistics); return statistics; }
@Around("@annotation(lifecycleTransition)") public Object checkTransition(ProceedingJoinPoint pjp, LifecycleTransition lifecycleTransition) throws Throwable{ // get the publication from the arguments for (Object obj : pjp.getArgs()) { if (obj instanceof Publication) { Publication publication = (Publication) obj; if (lifecycleTransition.fromStatus() != CvPublicationStatusType.PUB_STATUS) { if (!publication.getStatus().getIdentifier().equals(lifecycleTransition.fromStatus().identifier())) { throw new IllegalTransitionException("Transition '"+pjp.getSignature().getName()+"' cannot be applied to publication '"+ DebugUtil.annotatedObjectToString(publication, false)+ "' with state: '"+DebugUtil.cvObjectToSimpleString(publication.getStatus())+"'"); } } } } return pjp.proceed(); }
@Around("@annotation(lifecycleTransition)") public Object checkTransition(ProceedingJoinPoint pjp, LifecycleTransition lifecycleTransition) throws Throwable{ // get the publication from the arguments for (Object obj : pjp.getArgs()) { if (obj instanceof Publication) { Publication publication = (Publication) obj; if (lifecycleTransition.fromStatus() != CvPublicationStatusType.PUB_STATUS) { if (!publication.getStatus().getIdentifier().equals(lifecycleTransition.fromStatus().identifier())) { throw new IllegalTransitionException("Transition '"+pjp.getSignature().getName()+"' cannot be applied to publication '"+ DebugUtil.annotatedObjectToString(publication, false)+ "' with state: '"+DebugUtil.cvObjectToSimpleString(publication.getStatus())+"'"); } } } } return pjp.proceed(); }
@Transactional public User assignReviewer(Publication publication) { final User owner = publication.getCurrentOwner(); if (owner == null) { throw new IllegalArgumentException("Cannot assign a reviewer to a publication without owner: "+ DebugUtil.annotatedObjectToString(publication, false)); } // check if the curator has a "mentor" reviewer, the one that is supposed to check her entries while learning User reviewer = UserUtils.getMentorReviewer(IntactContext.getCurrentInstance(), owner); if (reviewer == null) { SelectionRandomizer<User> selectionRandomizer = createSelectionRandomizer(); reviewer = selectionRandomizer.randomSelection(owner); if (reviewer == null) { throw new IllegalStateException("No reviewers could be found"); } } publication.setCurrentReviewer(reviewer); return reviewer; }
@Transactional public User assignReviewer(Publication publication) { final User owner = publication.getCurrentOwner(); if (owner == null) { throw new IllegalArgumentException("Cannot assign a reviewer to a publication without owner: "+ DebugUtil.annotatedObjectToString(publication, false)); } // check if the curator has a "mentor" reviewer, the one that is supposed to check her entries while learning User reviewer = UserUtils.getMentorReviewer(IntactContext.getCurrentInstance(), owner); if (reviewer == null) { SelectionRandomizer<User> selectionRandomizer = createSelectionRandomizer(); reviewer = selectionRandomizer.randomSelection(owner); if (reviewer == null) { throw new IllegalStateException("No reviewers could be found"); } } publication.setCurrentReviewer(reviewer); return reviewer; }
@Transactional public PersisterStatistics saveOrUpdate( AnnotatedObject ao ) { if (log.isDebugEnabled()) log.debug("Saving: "+DebugUtil.annotatedObjectToString( ao, false )); dataContext.getDaoFactory().getEntityManager().setFlushMode(FlushModeType.COMMIT); //dataContext.getDaoFactory().getDataConfig().setAutoFlush(false); try { synchronize( ao ); commit(); } finally { dataContext.getDaoFactory().getEntityManager().setFlushMode(FlushModeType.AUTO); } reload( ao ); return statistics; }
@Transactional public PersisterStatistics saveOrUpdate( AnnotatedObject ao ) { if (log.isDebugEnabled()) log.debug("Saving: "+DebugUtil.annotatedObjectToString( ao, false )); dataContext.getDaoFactory().getEntityManager().setFlushMode(FlushModeType.COMMIT); //dataContext.getDaoFactory().getDataConfig().setAutoFlush(false); try { synchronize( ao ); commit(); } finally { dataContext.getDaoFactory().getEntityManager().setFlushMode(FlushModeType.AUTO); } reload( ao ); return statistics; }
for ( AnnotatedObject ao : annotatedObjectsToMerge.values() ) { if ( log.isDebugEnabled() ) { log.debug( "\tAbout to merge " + DebugUtil.annotatedObjectToString(ao, true) ); throw new IllegalStateException( "Object to persist should have an AC: " + DebugUtil.annotatedObjectToString(ao, true)); } else { daoFactory.getBaseDao().merge( ao );
for ( AnnotatedObject ao : annotatedObjectsToMerge.values() ) { if ( log.isDebugEnabled() ) { log.debug( "\tAbout to merge " + DebugUtil.annotatedObjectToString(ao, true) ); throw new IllegalStateException( "Object to persist should have an AC: " + DebugUtil.annotatedObjectToString(ao, true)); } else { daoFactory.getBaseDao().merge( ao );
/** * Create a publication object. * * @param publication the publication * @param mechanism mechanism of creation of the publication */ @LifecycleTransition(toStatus = CvPublicationStatusType.NEW) public void create(Publication publication, String mechanism) { if( publication.getStatus() != null ) { throw new IllegalTransitionException( "Cannot get publication in status NEW when it's status is already set ("+ publication.getStatus().getShortLabel() +"): " + DebugUtil.annotatedObjectToString(publication, false) ); } changeStatus(publication, CvPublicationStatusType.NEW, CvLifecycleEventType.CREATED, mechanism); // Notify listeners for ( LifecycleEventListener listener : getListeners() ) { listener.fireCreated( publication ); } } }
/** * Create a publication object. * * @param publication the publication * @param mechanism mechanism of creation of the publication */ @LifecycleTransition(toStatus = CvPublicationStatusType.NEW) public void create(Publication publication, String mechanism) { if( publication.getStatus() != null ) { throw new IllegalTransitionException( "Cannot get publication in status NEW when it's status is already set ("+ publication.getStatus().getShortLabel() +"): " + DebugUtil.annotatedObjectToString(publication, false) ); } changeStatus(publication, CvPublicationStatusType.NEW, CvLifecycleEventType.CREATED, mechanism); // Notify listeners for ( LifecycleEventListener listener : getListeners() ) { listener.fireCreated( publication ); } } }