From 1f473e6669a1eaacfccd3c032480e9dedaad002a Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 17 Feb 2015 08:54:49 +0000 Subject: [PATCH] Iron out SLC migration git-svn-id: https://svn.argeo.org/slc/trunk@7911 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- demo/modules/pom.xml | 3 - dep/org.argeo.slc.dep.backend/pom.xml | 3 +- dep/org.argeo.slc.dep.detached/p2.inf | 2 - dep/org.argeo.slc.dep.detached/pom.xml | 34 ------- dep/org.argeo.slc.dep.eclipse/pom.xml | 2 +- dep/org.argeo.slc.dep.minimal/pom.xml | 3 +- dep/org.argeo.slc.dep.rap/pom.xml | 2 +- .../org.argeo.slc.client.rcp/.classpath | 2 +- org.argeo.slc.client.rap/.classpath | 2 +- org.argeo.slc.client.rap/bnd.bnd | 6 +- org.argeo.slc.client.rap/plugin.xml | 2 +- org.argeo.slc.client.ui.dist/.classpath | 4 +- org.argeo.slc.client.ui.dist/bnd.bnd | 5 +- org.argeo.slc.client.ui/.classpath | 4 +- org.argeo.slc.client.ui/bnd.bnd | 6 +- org.argeo.slc.unit/bnd.bnd | 2 + org.argeo.slc.unit/pom.xml | 5 + .../argeo/slc/unit/db/DbUnitDeployment.java | 95 +++++++++++++++++++ .../slc/unit/db/DbUnitDeploymentData.java | 45 +++++++++ 19 files changed, 172 insertions(+), 55 deletions(-) delete mode 100644 dep/org.argeo.slc.dep.detached/p2.inf delete mode 100644 dep/org.argeo.slc.dep.detached/pom.xml create mode 100644 org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeployment.java create mode 100644 org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeploymentData.java diff --git a/demo/modules/pom.xml b/demo/modules/pom.xml index 442d5056a..4bf6764b7 100644 --- a/demo/modules/pom.xml +++ b/demo/modules/pom.xml @@ -35,9 +35,6 @@ default - net.sf.cglib.core, - net.sf.cglib.proxy, - net.sf.cglib.reflect, org.aopalliance.aop, org.argeo.slc.core.execution, org.argeo.slc.core.execution.tasks, diff --git a/dep/org.argeo.slc.dep.backend/pom.xml b/dep/org.argeo.slc.dep.backend/pom.xml index b128cd7f4..f369a2c86 100644 --- a/dep/org.argeo.slc.dep.backend/pom.xml +++ b/dep/org.argeo.slc.dep.backend/pom.xml @@ -7,8 +7,7 @@ .. org.argeo.slc.dep.backend - SLC Backend Dependencies - Shared by RAP and pure server + SLC Backend diff --git a/dep/org.argeo.slc.dep.detached/p2.inf b/dep/org.argeo.slc.dep.detached/p2.inf deleted file mode 100644 index 0423aa509..000000000 --- a/dep/org.argeo.slc.dep.detached/p2.inf +++ /dev/null @@ -1,2 +0,0 @@ -properties.1.name=org.eclipse.equinox.p2.type.category -properties.1.value=true \ No newline at end of file diff --git a/dep/org.argeo.slc.dep.detached/pom.xml b/dep/org.argeo.slc.dep.detached/pom.xml deleted file mode 100644 index a3805d11a..000000000 --- a/dep/org.argeo.slc.dep.detached/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - org.argeo.slc - dep - 2.1.1-SNAPSHOT - .. - - org.argeo.slc.dep.detached - jar - SLC Detached Dependencies - - - org.argeo.slc - org.argeo.slc.detached - 2.1.1-SNAPSHOT - - - org.argeo.slc - org.argeo.slc.support.jemmy - 2.1.1-SNAPSHOT - - - org.argeo.slc - org.argeo.slc.ext.castor - 2.1.1-SNAPSHOT - - - - org.argeo.tp - mx4j - - - \ No newline at end of file diff --git a/dep/org.argeo.slc.dep.eclipse/pom.xml b/dep/org.argeo.slc.dep.eclipse/pom.xml index a2de2acb5..5653d1393 100644 --- a/dep/org.argeo.slc.dep.eclipse/pom.xml +++ b/dep/org.argeo.slc.dep.eclipse/pom.xml @@ -7,7 +7,7 @@ .. org.argeo.slc.dep.eclipse - SLC Eclipse Dependencies + SLC Eclipse diff --git a/dep/org.argeo.slc.dep.minimal/pom.xml b/dep/org.argeo.slc.dep.minimal/pom.xml index 0b2a6a544..8794d4302 100644 --- a/dep/org.argeo.slc.dep.minimal/pom.xml +++ b/dep/org.argeo.slc.dep.minimal/pom.xml @@ -8,8 +8,7 @@ .. org.argeo.slc.dep.minimal - SLC Minimal Dependencies - The minimal set of dependencies required to run an SLC execution + SLC Minimal diff --git a/dep/org.argeo.slc.dep.rap/pom.xml b/dep/org.argeo.slc.dep.rap/pom.xml index 0f68a548c..797f1bb5f 100644 --- a/dep/org.argeo.slc.dep.rap/pom.xml +++ b/dep/org.argeo.slc.dep.rap/pom.xml @@ -8,7 +8,7 @@ .. org.argeo.slc.dep.rap - SLC Eclipse RAP Dependencies + SLC Eclipse RAP diff --git a/legacy/plugins/org.argeo.slc.client.rcp/.classpath b/legacy/plugins/org.argeo.slc.client.rcp/.classpath index 848725036..57ffbb6c8 100644 --- a/legacy/plugins/org.argeo.slc.client.rcp/.classpath +++ b/legacy/plugins/org.argeo.slc.client.rcp/.classpath @@ -1,7 +1,7 @@ - + diff --git a/org.argeo.slc.client.rap/.classpath b/org.argeo.slc.client.rap/.classpath index e2c2faee5..06bea9468 100644 --- a/org.argeo.slc.client.rap/.classpath +++ b/org.argeo.slc.client.rap/.classpath @@ -1,7 +1,7 @@ - + >> diff --git a/org.argeo.slc.client.rap/bnd.bnd b/org.argeo.slc.client.rap/bnd.bnd index 37cffce2e..f772f5886 100644 --- a/org.argeo.slc.client.rap/bnd.bnd +++ b/org.argeo.slc.client.rap/bnd.bnd @@ -1,7 +1,11 @@ Bundle-SymbolicName: org.argeo.slc.client.rap;singleton=true Bundle-ActivationPolicy: lazy - Bundle-Activator: org.argeo.slc.client.rap.SlcRapPlugin +Require-Bundle: org.eclipse.ui;resolution:=optional,\ +org.eclipse.core.runtime,\ +org.eclipse.rap.ui;resolution:=optional,\ +org.eclipse.rap.ui.workbench;resolution:=optional + Import-Package: javax.jcr.nodetype,\ javax.servlet,\ javax.servlet.http,\ diff --git a/org.argeo.slc.client.rap/plugin.xml b/org.argeo.slc.client.rap/plugin.xml index 6e71fa27e..c64cdf9e8 100644 --- a/org.argeo.slc.client.rap/plugin.xml +++ b/org.argeo.slc.client.rap/plugin.xml @@ -6,7 +6,7 @@ + path="slc"> diff --git a/org.argeo.slc.client.ui.dist/.classpath b/org.argeo.slc.client.ui.dist/.classpath index 5641c7ca3..120e381bb 100644 --- a/org.argeo.slc.client.ui.dist/.classpath +++ b/org.argeo.slc.client.ui.dist/.classpath @@ -1,7 +1,7 @@ - - >> + + diff --git a/org.argeo.slc.client.ui.dist/bnd.bnd b/org.argeo.slc.client.ui.dist/bnd.bnd index 9ecad5935..600659884 100644 --- a/org.argeo.slc.client.ui.dist/bnd.bnd +++ b/org.argeo.slc.client.ui.dist/bnd.bnd @@ -1,6 +1,9 @@ Bundle-SymbolicName: org.argeo.slc.client.ui.distp;singleton=true Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.ui;resolution:=optional +Require-Bundle: org.eclipse.ui;resolution:=optional,\ +org.eclipse.core.runtime,\ +org.eclipse.rap.ui;resolution:=optional,\ +org.eclipse.rap.ui.workbench;resolution:=optional Bundle-Activator: org.argeo.slc.client.ui.dist.DistPlugin Import-Package: org.argeo.eclipse.spring,\ diff --git a/org.argeo.slc.client.ui/.classpath b/org.argeo.slc.client.ui/.classpath index 5641c7ca3..120e381bb 100644 --- a/org.argeo.slc.client.ui/.classpath +++ b/org.argeo.slc.client.ui/.classpath @@ -1,7 +1,7 @@ - - >> + + diff --git a/org.argeo.slc.client.ui/bnd.bnd b/org.argeo.slc.client.ui/bnd.bnd index 435d28a29..479968ac5 100644 --- a/org.argeo.slc.client.ui/bnd.bnd +++ b/org.argeo.slc.client.ui/bnd.bnd @@ -1,8 +1,12 @@ Bundle-SymbolicName: org.argeo.slc.client.ui;singleton=true Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.ui;resolution:=optional +Require-Bundle: org.eclipse.ui;resolution:=optional,\ +org.eclipse.core.runtime,\ +org.eclipse.rap.ui;resolution:=optional,\ +org.eclipse.rap.ui.workbench;resolution:=optional Bundle-Activator: org.argeo.slc.client.ui.ClientUiPlugin Import-Package: org.argeo.eclipse.spring,\ org.argeo.security.ui,\ +org.eclipse.core.runtime,\ * diff --git a/org.argeo.slc.unit/bnd.bnd b/org.argeo.slc.unit/bnd.bnd index e69de29bb..0c604e6a2 100644 --- a/org.argeo.slc.unit/bnd.bnd +++ b/org.argeo.slc.unit/bnd.bnd @@ -0,0 +1,2 @@ +Import-Package: org.springframework.core,\ +* \ No newline at end of file diff --git a/org.argeo.slc.unit/pom.xml b/org.argeo.slc.unit/pom.xml index 8c1ceca6a..ac85574d2 100644 --- a/org.argeo.slc.unit/pom.xml +++ b/org.argeo.slc.unit/pom.xml @@ -23,5 +23,10 @@ org.argeo.slc.core 2.1.1-SNAPSHOT + + org.argeo.slc + org.argeo.slc.support + 2.1.1-SNAPSHOT + \ No newline at end of file diff --git a/org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeployment.java b/org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeployment.java new file mode 100644 index 000000000..25ecb0648 --- /dev/null +++ b/org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeployment.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.slc.unit.db; + +import java.sql.SQLException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.slc.SlcException; +import org.argeo.slc.UnsupportedException; +import org.argeo.slc.build.Distribution; +import org.argeo.slc.deploy.DeployedSystem; +import org.argeo.slc.deploy.Deployment; +import org.argeo.slc.deploy.DeploymentData; +import org.argeo.slc.deploy.TargetData; +import org.argeo.slc.support.deploy.db.DbModel; +import org.argeo.slc.support.deploy.db.JdbcAware; +import org.dbunit.DataSourceDatabaseTester; +import org.dbunit.DatabaseUnitException; +import org.dbunit.IDatabaseTester; +import org.dbunit.database.IDatabaseConnection; +import org.dbunit.dataset.IDataSet; +import org.dbunit.operation.DatabaseOperation; + +public class DbUnitDeployment implements Deployment { + private static Log log = LogFactory.getLog(DbUnitDeployment.class); + + private JdbcAware jdbcAware; + private DbUnitDeploymentData deploymentData; + private DbModel dbModel; + + public void run() { + try { + IDatabaseTester databaseTester = new DataSourceDatabaseTester( + jdbcAware.getDataSource()); + databaseTester.setSetUpOperation(new DatabaseOperation() { + + @Override + public void execute(IDatabaseConnection connection, + IDataSet dataSet) throws DatabaseUnitException, + SQLException { + if (dbModel != null) { + dbModel.createSchema(connection.getConnection()); + DatabaseOperation.INSERT.execute(connection, dataSet); + } else { + DatabaseOperation.UPDATE.execute(connection, dataSet); + } + } + + }); + databaseTester.setDataSet(deploymentData.createDataSet()); + databaseTester.onSetup(); + databaseTester.onTearDown(); + + log.info("Database deployed."); + } catch (Exception e) { + throw new SlcException("Could not initialize the database", e); + } + } + + public DeployedSystem getDeployedSystem() { + throw new UnsupportedOperationException(); + } + + public void setDbModel(DbModel dbModel) { + this.dbModel = dbModel; + } + + public void setDeploymentData(DeploymentData deploymentData) { + this.deploymentData = (DbUnitDeploymentData) deploymentData; + } + + public void setTargetData(TargetData targetData) { + this.jdbcAware = (JdbcAware) targetData; + + } + + public void setDistribution(Distribution distribution) { + throw new UnsupportedException("Method not supported"); + } + +} diff --git a/org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeploymentData.java b/org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeploymentData.java new file mode 100644 index 000000000..46835c6f6 --- /dev/null +++ b/org.argeo.slc.unit/src/org/argeo/slc/unit/db/DbUnitDeploymentData.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.slc.unit.db; + +import java.io.InputStream; + +import org.argeo.slc.SlcException; +import org.argeo.slc.deploy.DeploymentData; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.xml.FlatXmlDataSet; +import org.springframework.core.io.Resource; + +public class DbUnitDeploymentData implements DeploymentData { + private Resource dataSetLocation; + + public IDataSet createDataSet() { + try { + InputStream in = dataSetLocation.getInputStream(); + IDataSet dataSet = new FlatXmlDataSet(in); + in.close(); + return dataSet; + } catch (Exception e) { + throw new SlcException("Cannot create data set", e); + } + + } + + public void setDataSetLocation(Resource dataSetLocation) { + this.dataSetLocation = dataSetLocation; + } + +} -- 2.39.2