Package net.sf.basedb.core
Class ProjectSpecificAnnotationsManager
- java.lang.Object
-
- net.sf.basedb.core.ProjectSpecificAnnotationsManager
-
- All Implemented Interfaces:
TransactionalAction
class ProjectSpecificAnnotationsManager extends Object implements TransactionalAction
Internal class for keeping the "override_id" column in the "Annotations" table synchronized when annotations are creted and deleted.- Since:
- 3.10
- Author:
- nicklas
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ProjectSpecificAnnotationsManager.AnnotationInfo
Holds some information about the annotation that has been created.
-
Field Summary
Fields Modifier and Type Field Description private List<ProjectSpecificAnnotationsManager.AnnotationInfo>
createdInherited
private List<ProjectSpecificAnnotationsManager.AnnotationInfo>
createdPrimary
private Set<Integer>
deletedDefault
private Set<Integer>
deletedPrimary
private org.hibernate.query.Query<AnnotationData>
findProjectSpecific
private static boolean
isDebugEnabled
private static org.slf4j.Logger
log
private org.hibernate.Session
session
-
Constructor Summary
Constructors Constructor Description ProjectSpecificAnnotationsManager(org.hibernate.Session session)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static int
cleanupProjectSpecificAnnotations()
Delete project-specific annotations that belong to projects that no longer exists.(package private) void
defaultDeleted(int id, boolean isPrimary)
A default annotation is being deleted in this transaction.(package private) int
deleteAnnotationsForNonExistingProjects()
(package private) Annotation
findProjectSpecificAnnotation(Annotation defaultAnnotation, int projectId)
Find a project-specific annotation for a given default annotation.(package private) void
inheritedCreated(int id, int annotationSet, int parent, int parentSet, int parentOverride, int project)
An INHERITED/CLONED annotation has been created in this transaction.void
onAfterCommit()
Called after a successful commit.void
onBeforeCommit()
This method is called before the commit is about to happen.void
onRollback()
Called after an unsuccessful commit.(package private) void
primaryCreated(int id, int annotationSet, int annotationType, int project)
A PRIMARY annotation has been created in this transaction.
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
isDebugEnabled
private static final boolean isDebugEnabled
-
session
private final org.hibernate.Session session
-
createdPrimary
private final List<ProjectSpecificAnnotationsManager.AnnotationInfo> createdPrimary
-
createdInherited
private final List<ProjectSpecificAnnotationsManager.AnnotationInfo> createdInherited
-
findProjectSpecific
private org.hibernate.query.Query<AnnotationData> findProjectSpecific
-
-
Method Detail
-
cleanupProjectSpecificAnnotations
static int cleanupProjectSpecificAnnotations() throws BaseException
Delete project-specific annotations that belong to projects that no longer exists.- Returns:
- The number of deleted annotation sets
- Throws:
BaseException
-
findProjectSpecificAnnotation
Annotation findProjectSpecificAnnotation(Annotation defaultAnnotation, int projectId)
Find a project-specific annotation for a given default annotation.
-
primaryCreated
void primaryCreated(int id, int annotationSet, int annotationType, int project)
A PRIMARY annotation has been created in this transaction. If this is a DEFAULT annotation (projectId==0) we need to set "override_id" for project-specific annotations to point to this annotation. If this is a PROJECT-SPECIFIC annotation (projectId!=0) we need to find the ID of the default annotation.- Parameters:
id
- The annotation that was createdannotationSet
- The annotation set the annotation belongs toannotationType
- The annotation type of the annotationproject
- The id of the project, or 0 for default annotation
-
inheritedCreated
void inheritedCreated(int id, int annotationSet, int parent, int parentSet, int parentOverride, int project)
An INHERITED/CLONED annotation has been created in this transaction. If this is a DEFAULT annotation (projectId==0) we need to set "override_id" for project-specific annotations to point to this annotation. If this is a PROJECT-SPECIFIC annotation (projectId!=0) we need to find the ID of the default annotation.- Parameters:
id
- The annotation that was createdannotationSet
- The annotation set the annotation belongs toparent
- The id of the parent annotationparentSet
- The id of the parent annotation setparentOverride
- The "override_id" column from the parent annotationproject
- The id of the project, or 0 for default annotation
-
defaultDeleted
void defaultDeleted(int id, boolean isPrimary)
A default annotation is being deleted in this transaction. We need to set override_id=0 on all other annotations that are referencing this annotation. This method can be used for both primary, inherited and cloned annotations.
-
onBeforeCommit
public void onBeforeCommit()
Description copied from interface:TransactionalAction
This method is called before the commit is about to happen. If this method throws an exception the transaction will be rolled back.- Specified by:
onBeforeCommit
in interfaceTransactionalAction
-
onAfterCommit
public void onAfterCommit()
Description copied from interface:TransactionalAction
Called after a successful commit. Implementations should not throw any exceptions from this method. If they do, the message is logged, by no other action is taken.- Specified by:
onAfterCommit
in interfaceTransactionalAction
-
onRollback
public void onRollback()
Description copied from interface:TransactionalAction
Called after an unsuccessful commit. Implementations should not throw any exceptions from this method. If they do, the message is logged, by no other action is taken.- Specified by:
onRollback
in interfaceTransactionalAction
-
deleteAnnotationsForNonExistingProjects
int deleteAnnotationsForNonExistingProjects()
-
-