summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntje Fuhrmann2012-10-22 05:02:22 (EDT)
committer Stephan Born2012-10-22 05:02:22 (EDT)
commit216144aa6ea62290b474c992e49a0317c8e9d527 (patch)
tree0c6cd18c46eff821d87add51126b33f25497594c
parent3f08924f82f93d231512d6dc4536257461aac3e5 (diff)
downloadorg.eclipse.stardust.engine-216144aa6ea62290b474c992e49a0317c8e9d527.zip
org.eclipse.stardust.engine-216144aa6ea62290b474c992e49a0317c8e9d527.tar.gz
org.eclipse.stardust.engine-216144aa6ea62290b474c992e49a0317c8e9d527.tar.bz2
Jira-ID: CRNT-26538
Provide Partition create/drop API git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/engine@60210 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/pojo/AuditTrailPartitionManager.java37
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java72
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/SchemaHelper.java68
3 files changed, 108 insertions, 69 deletions
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/pojo/AuditTrailPartitionManager.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/pojo/AuditTrailPartitionManager.java
new file mode 100644
index 0000000..b95697a
--- /dev/null
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/pojo/AuditTrailPartitionManager.java
@@ -0,0 +1,37 @@
+package org.eclipse.stardust.engine.api.pojo;
+
+import java.sql.SQLException;
+
+import org.eclipse.stardust.engine.cli.sysconsole.utils.Utils;
+import org.eclipse.stardust.engine.core.runtime.beans.SchemaHelper;
+
+public class AuditTrailPartitionManager
+{
+
+ /**
+ * Creates a new partition with the given partitionId, if no partition having this id
+ * currently exists.
+ *
+ * @param partitionId - The id of the partition to be created.
+ * @param password - The password of the sysconsole.
+ * @throws SQLException
+ */
+ public static void createAuditTrailPartition(String partitionId, String password)
+ throws SQLException
+ {
+ SchemaHelper.alterAuditTrailCreatePartition(password, partitionId, null, null);
+ }
+
+ /**
+ * Deletes the partition identified by the given partitionId.
+ *
+ * @param partitionId - The id of the partition to be deleted.
+ * @param password - The password of the sysconsole.
+ */
+ public static void dropAuditTrailPartition(String partitionId, String password)
+ {
+ Utils.initCarnotEngine(partitionId);
+ SchemaHelper.alterAuditTrailDropPartition(partitionId);
+ }
+
+}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java
index d029b9a..e5983a8 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java
@@ -15,7 +15,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.sql.SQLException;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.stardust.common.StringUtils;
@@ -28,13 +27,10 @@ import org.eclipse.stardust.common.utils.console.Options;
import org.eclipse.stardust.engine.cli.sysconsole.consistency.AuditTrailConsistencyChecker;
import org.eclipse.stardust.engine.cli.sysconsole.consistency.SharedDocumentDataConsistencyCheck;
import org.eclipse.stardust.engine.cli.sysconsole.utils.Utils;
-import org.eclipse.stardust.engine.core.persistence.Predicates;
-import org.eclipse.stardust.engine.core.persistence.QueryExtension;
import org.eclipse.stardust.engine.core.persistence.jdbc.DBMSKey;
-import org.eclipse.stardust.engine.core.persistence.jdbc.Session;
import org.eclipse.stardust.engine.core.persistence.jdbc.SessionFactory;
import org.eclipse.stardust.engine.core.persistence.jdbc.SessionProperties;
-import org.eclipse.stardust.engine.core.runtime.beans.*;
+import org.eclipse.stardust.engine.core.runtime.beans.SchemaHelper;
import org.eclipse.stardust.engine.core.runtime.beans.removethis.KernelTweakingProperties;
@@ -303,71 +299,9 @@ public class AlterAuditTrailCommand extends AuditTrailCommand
print("Deletes the partition and any contained data from the AuditTrail.");
String partitionId = (String) options.get(PARTITION_DROP);
- Utils.initCarnotEngine(partitionId);
- IAuditTrailPartition partition = AuditTrailPartitionBean.findById(partitionId);
- Session session = (Session) SessionFactory
- .getSession(SessionFactory.AUDIT_TRAIL);
-
- // Delete for all models in given partition the runtime data (process instances, ...).
- Iterator iter = session.getIterator(ModelPersistorBean.class, QueryExtension
- .where(Predicates.isEqual(ModelPersistorBean.FR__PARTITION, partition
- .getOID())));
- while (iter.hasNext())
- {
- ModelPersistorBean model = (ModelPersistorBean) iter.next();
- AdminServiceUtils.deleteModelRuntimePart(model.getOID(), session, true);
- }
-
- // Delete runtime data which does not depend on any model in given partition.
- // loginUserOid can be 0 because keepLoginUser = false.
- AdminServiceUtils.deleteModelIndependentRuntimeData(false, false, session, 0,
- partition.getOID());
-
- // Delete for all model the definition data (process definition, ...).
- iter = session.getIterator(ModelPersistorBean.class, QueryExtension
- .where(Predicates.isEqual(ModelPersistorBean.FR__PARTITION, partition
- .getOID())));
- while (iter.hasNext())
- {
- ModelPersistorBean model = (ModelPersistorBean) iter.next();
- AdminServiceUtils.deleteModelModelingPart(model.getOID(), session);
- model.delete();
- }
-
- // Delete ProcessInstanceLinkTypes
- session.delete(ProcessInstanceLinkTypeBean.class,
- Predicates.isEqual(ProcessInstanceLinkTypeBean.FR__PARTITION, partition.getOID()),
- false);
-
- // Delete partition scope preferences
- AdminServiceUtils.deletePartitionPreferences(partition.getOID(), session);
-
- // There should only be one for this partition. But to be on the save side...
- iter = session.getIterator(UserDomainBean.class, QueryExtension.where(Predicates
- .isEqual(UserDomainBean.FR__PARTITION, partition.getOID())));
- while (iter.hasNext())
- {
- IUserDomain domain = (IUserDomain) iter.next();
- domain.delete();
- }
-
- // There should only be one for this partition. But to be on the save side...
- iter = session.getIterator(UserRealmBean.class, QueryExtension.where(Predicates
- .isEqual(UserRealmBean.FR__PARTITION, partition.getOID())));
- while (iter.hasNext())
- {
- IUserRealm realm = (IUserRealm) iter.next();
-
- session.delete(UserBean.class, Predicates.isEqual(UserBean.FR__REALM, realm
- .getOID()), false);
-
- realm.delete();
- }
-
- partition.delete();
-
- session.save(true);
+ Utils.initCarnotEngine(partitionId);
+ SchemaHelper.alterAuditTrailDropPartition(partitionId);
print("Deletion of partition and contained data from AuditTrail done.");
}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/SchemaHelper.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/SchemaHelper.java
index 7da986d..46c243a 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/SchemaHelper.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/SchemaHelper.java
@@ -29,6 +29,7 @@ import org.eclipse.stardust.engine.api.model.PredefinedConstants;
import org.eclipse.stardust.engine.api.runtime.PredefinedProcessInstanceLinkTypes;
import org.eclipse.stardust.engine.core.persistence.Predicates;
import org.eclipse.stardust.engine.core.persistence.QueryDescriptor;
+import org.eclipse.stardust.engine.core.persistence.QueryExtension;
import org.eclipse.stardust.engine.core.persistence.jdbc.*;
import org.eclipse.stardust.engine.core.runtime.beans.removethis.SecurityProperties;
import org.eclipse.stardust.engine.core.runtime.setup.DataCluster;
@@ -1363,6 +1364,73 @@ public class SchemaHelper
ParametersFacade.popLayer();
}
}
+
+ public static void alterAuditTrailDropPartition(String partitionId)
+ {
+ IAuditTrailPartition partition = AuditTrailPartitionBean.findById(partitionId);
+ Session session = (Session) SessionFactory
+ .getSession(SessionFactory.AUDIT_TRAIL);
+
+ // Delete for all models in given partition the runtime data (process instances, ...).
+ Iterator iter = session.getIterator(ModelPersistorBean.class, QueryExtension
+ .where(Predicates.isEqual(ModelPersistorBean.FR__PARTITION, partition
+ .getOID())));
+ while (iter.hasNext())
+ {
+ ModelPersistorBean model = (ModelPersistorBean) iter.next();
+ AdminServiceUtils.deleteModelRuntimePart(model.getOID(), session, true);
+ }
+
+ // Delete runtime data which does not depend on any model in given partition.
+ // loginUserOid can be 0 because keepLoginUser = false.
+ AdminServiceUtils.deleteModelIndependentRuntimeData(false, false, session, 0,
+ partition.getOID());
+
+ // Delete for all model the definition data (process definition, ...).
+ iter = session.getIterator(ModelPersistorBean.class, QueryExtension
+ .where(Predicates.isEqual(ModelPersistorBean.FR__PARTITION, partition
+ .getOID())));
+ while (iter.hasNext())
+ {
+ ModelPersistorBean model = (ModelPersistorBean) iter.next();
+ AdminServiceUtils.deleteModelModelingPart(model.getOID(), session);
+ model.delete();
+ }
+
+ // Delete ProcessInstanceLinkTypes
+ session.delete(ProcessInstanceLinkTypeBean.class,
+ Predicates.isEqual(ProcessInstanceLinkTypeBean.FR__PARTITION, partition.getOID()),
+ false);
+
+ // Delete partition scope preferences
+ AdminServiceUtils.deletePartitionPreferences(partition.getOID(), session);
+
+ // There should only be one for this partition. But to be on the save side...
+ iter = session.getIterator(UserDomainBean.class, QueryExtension.where(Predicates
+ .isEqual(UserDomainBean.FR__PARTITION, partition.getOID())));
+ while (iter.hasNext())
+ {
+ IUserDomain domain = (IUserDomain) iter.next();
+ domain.delete();
+ }
+
+ // There should only be one for this partition. But to be on the save side...
+ iter = session.getIterator(UserRealmBean.class, QueryExtension.where(Predicates
+ .isEqual(UserRealmBean.FR__PARTITION, partition.getOID())));
+ while (iter.hasNext())
+ {
+ IUserRealm realm = (IUserRealm) iter.next();
+
+ session.delete(UserBean.class, Predicates.isEqual(UserBean.FR__REALM, realm
+ .getOID()), false);
+
+ realm.delete();
+ }
+
+ partition.delete();
+
+ session.save(true);
+ }
public static void alterAuditTrailListPartitions(String sysconPassword)
throws SQLException