Revision: 3383
Author: ferguson.sebastian
Date: Wed Mar 17 13:09:48 2010
Log: KettleJob settings are now sent to the server. Removed an unused field from the conflict resolver. Explained what the new 'enterprise' field is for.
http://code.google.com/p/power-architect/source/detail?r=3383

Added:
 /trunk/src/ca/sqlpower/architect/etl/kettle/KettleSettings.java
Modified:
 /trunk/src/ca/sqlpower/architect/ArchitectProject.java
 /trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
 /trunk/src/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
 /trunk/src/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
 /trunk/src/ca/sqlpower/architect/etl/kettle/KettleJob.java
 /trunk/src/ca/sqlpower/architect/swingui/DataMoverPanel.java
 /trunk/src/ca/sqlpower/architect/swingui/KettleJobPanel.java

=======================================
--- /dev/null
+++ /trunk/src/ca/sqlpower/architect/etl/kettle/KettleSettings.java Wed Mar 17 13:09:48 2010
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of Power*Architect.
+ *
+ * Power*Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Power*Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.etl.kettle;
+
+import java.util.Collections;
+import java.util.List;
+
+import ca.sqlpower.object.AbstractSPObject;
+import ca.sqlpower.object.SPObject;
+import ca.sqlpower.object.annotation.Accessor;
+import ca.sqlpower.object.annotation.Constructor;
+import ca.sqlpower.object.annotation.Mutator;
+import ca.sqlpower.sql.JDBCDataSource;
+
+public class KettleSettings extends AbstractSPObject {
+
+    /**
+     * The name of the Kettle job
+     */
+    private String jobName = "";
+
+    /**
+     * The name of the target schema
+     */
+    private String schemaName = "";
+
+    /**
+     * The path to store the Kettle job at
+     */
+    private String filePath = "";
+
+    /**
+ * The default join type for Kettle. The join types are stored as int as the values
+     * are in an array in Kettle.
+     */
+    private int joinType = 0;
+
+    /**
+ * The SPDataSource representation of the database with the Kettle repository we want to save to
+     */
+    private JDBCDataSource repository;
+
+    /**
+ * A flag that determines whether we will save the job to an xml file or a Kettle repository
+     */
+    private boolean savingToFile = true;
+
+    @Constructor
+    public KettleSettings() {
+        setName("Kettle Settings");
+    }
+
+    @Accessor
+    public String getJobName() {
+        return jobName;
+    }
+
+    @Mutator
+    public void setJobName(String v) {
+        String oldJobName = jobName;
+        jobName = v;
+        firePropertyChange("jobName", oldJobName, jobName);
+    }
+
+    @Accessor
+    public String getSchemaName() {
+        return schemaName;
+    }
+
+    @Mutator
+    public void setSchemaName(String v) {
+        String oldSchemaName = schemaName;
+        schemaName = v;
+        firePropertyChange("schemaName", oldSchemaName, schemaName);
+    }
+
+    @Accessor
+    public String getFilePath() {
+        return filePath;
+    }
+
+    @Mutator
+    public void setFilePath(String v) {
+        String oldFilePath = filePath;
+        filePath = v;
+        firePropertyChange("filePath", oldFilePath, filePath);
+    }
+
+    @Accessor
+    public int getJoinType() {
+        return joinType;
+    }
+
+    @Mutator
+    public void setJoinType(int v) {
+        int oldJoinType = joinType;
+        joinType = v;
+        firePropertyChange("joinType", oldJoinType, joinType);
+    }
+
+    @Accessor
+    public JDBCDataSource getRepository() {
+        return repository;
+    }
+
+    @Mutator
+    public void setRepository(JDBCDataSource v) {
+        JDBCDataSource oldRepository = repository;
+        repository = v;
+        firePropertyChange("repository", oldRepository, repository);
+    }
+
+    @Accessor
+    public boolean isSavingToFile() {
+        return savingToFile;
+    }
+
+    @Mutator
+    public void setSavingToFile(boolean v) {
+        boolean oldSavingToFile = savingToFile;
+        savingToFile = v;
+        firePropertyChange("savingToFile", oldSavingToFile, savingToFile);
+    }
+
+    @Override
+    protected boolean removeChildImpl(SPObject child) {
+        return false;
+    }
+
+    public boolean allowsChildren() {
+        return false;
+    }
+
+    public int childPositionOffset(Class<? extends SPObject> childType) {
+        return 0;
+    }
+
+    public List<Class<? extends SPObject>> getAllowedChildTypes() {
+        return Collections.emptyList();
+    }
+
+    public List<? extends SPObject> getChildren() {
+        return Collections.emptyList();
+    }
+
+    public List<? extends SPObject> getDependencies() {
+        return null;
+    }
+
+    public void removeDependency(SPObject dependency) {
+    }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectProject.java Mon Mar 15 13:05:06 2010 +++ /trunk/src/ca/sqlpower/architect/ArchitectProject.java Wed Mar 17 13:09:48 2010
@@ -24,6 +24,7 @@
 import java.util.Collections;
 import java.util.List;

+import ca.sqlpower.architect.etl.kettle.KettleSettings;
 import ca.sqlpower.architect.olap.OLAPRootObject;
 import ca.sqlpower.architect.profile.ProfileManager;
 import ca.sqlpower.object.AbstractSPObject;
@@ -61,7 +62,7 @@
     @SuppressWarnings("unchecked")
     public static List<Class<? extends SPObject>> allowedChildTypes =
Collections.unmodifiableList(new ArrayList<Class<? extends SPObject>>( - Arrays.asList(SQLObjectRoot.class, ProfileManager.class, OLAPRootObject.class))); + Arrays.asList(SQLObjectRoot.class, ProfileManager.class, OLAPRootObject.class, KettleSettings.class)));

     /**
      * There is a 1:1 ratio between the session and the project.
@@ -80,14 +81,15 @@
      */
     private SourceObjectIntegrityWatcher currentWatcher;

+    private final KettleSettings kettleSettings;
+
     /**
* Constructs an architect project. The init method must be called immediately
      * after creating a project.
      * @throws SQLObjectException
      */
     public ArchitectProject() throws SQLObjectException {
-        this(new SQLObjectRoot(), new OLAPRootObject());
-
+ this(new SQLObjectRoot(), new OLAPRootObject(), new KettleSettings());
         SQLDatabase targetDatabase = new SQLDatabase();
         targetDatabase.setPlayPenDatabase(true);
         rootObject.addChild(targetDatabase, 0);
@@ -104,12 +106,15 @@
     @Constructor
     public ArchitectProject(
@ConstructorParameter(isProperty=ParameterType.CHILD, propertyName="rootObject") SQLObjectRoot rootObject, - @ConstructorParameter(isProperty=ParameterType.CHILD, propertyName="olapRootObject") OLAPRootObject olapRootObject) + @ConstructorParameter(isProperty=ParameterType.CHILD, propertyName="olapRootObject") OLAPRootObject olapRootObject, + @ConstructorParameter(isProperty=ParameterType.CHILD, propertyName="kettleSettings") KettleSettings kettleSettings)
             throws SQLObjectException {
         this.rootObject = rootObject;
         rootObject.setParent(this);
         this.olapRootObject = olapRootObject;
         olapRootObject.setParent(this);
+        this.kettleSettings = kettleSettings;
+        kettleSettings.setParent(this);
         setName("Architect Project");
     }

@@ -250,6 +255,7 @@
             allChildren.add(profileManager);
         }
         allChildren.add(olapRootObject);
+        allChildren.add(kettleSettings);
         return allChildren;
     }

@@ -262,6 +268,7 @@
         rootObject.removeDependency(dependency);
         profileManager.removeDependency(dependency);
         olapRootObject.removeDependency(dependency);
+        kettleSettings.removeDependency(dependency);
     }

     protected void addChildImpl(SPObject child, int index) {
@@ -277,4 +284,9 @@
     public OLAPRootObject getOlapRootObject() {
         return olapRootObject;
     }
-}
+
+    @NonProperty
+    public KettleSettings getKettleSettings() {
+        return kettleSettings;
+    }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Tue Mar 16 11:16:06 2010 +++ /trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Wed Mar 17 13:09:48 2010
@@ -152,6 +152,7 @@

                outboundHttpClient = 
createHttpClient(projectLocation.getServiceInfo());
                dataSourceCollection = getDataSources();
+
sessionPersister = new ArchitectSessionPersister("inbound-" + projectLocation.getUUID(), getWorkspace(), new SessionPersisterSuperConverter(dataSourceCollection, getWorkspace()));
                sessionPersister.setSession(this);
@@ -255,7 +256,6 @@
                SQLPowerUtils.listenToHierarchy(getWorkspace(), listener);

                updater.setListener(listener);
-               updater.setPersister(sessionPersister);
updater.setConverter(new SessionPersisterSuperConverter(dataSourceCollection, getWorkspace()));
                updater.start();

=======================================
--- /trunk/src/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java Fri Mar 12 15:01:53 2010 +++ /trunk/src/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java Wed Mar 17 13:09:48 2010
@@ -23,6 +23,7 @@
 import java.util.List;

 import ca.sqlpower.architect.ArchitectProject;
+import ca.sqlpower.architect.etl.kettle.KettleSettings;
 import ca.sqlpower.architect.olap.OLAPRootObject;
 import ca.sqlpower.dao.PersistedSPOProperty;
 import ca.sqlpower.dao.PersistedSPObject;
@@ -62,6 +63,14 @@
         architectProject.getOlapRootObject().setUUID(olapRootObjectUUID);
         persistedOlapRootObject.setLoaded(true);

+ String kettleSettingsUUID = (String) AbstractSPPersisterHelper.findPropertyAndRemove(
+                pso.getUUID(), "kettleSettings", persistedProperties);
+
+ PersistedSPObject persistedKettleSettings = AbstractSPPersisterHelper.findPersistedSPObject( + pso.getUUID(), KettleSettings.class.getName(), kettleSettingsUUID, persistedObjects);
+        persistedKettleSettings.setLoaded(true);
+        architectProject.getKettleSettings().setUUID(kettleSettingsUUID);
+
List<PersistedSPObject> databases = new ArrayList<PersistedSPObject>();
         for (PersistedSPObject o : persistedObjects) {
if (o.getParentUUID().equals(architectProject.getRootObject().getUUID()) &&
=======================================
--- /trunk/src/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java Mon Mar 15 12:14:01 2010 +++ /trunk/src/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java Wed Mar 17 13:09:48 2010
@@ -60,7 +60,6 @@
     private boolean updating = false;

     private SPPersisterListener listener;
-    private SPSessionPersister persister;
     private SessionPersisterSuperConverter converter;
     private final SPSession session;

@@ -119,10 +118,6 @@
     public void setConverter(SessionPersisterSuperConverter converter) {
         this.converter = converter;
     }
-
-    public void setPersister(SPSessionPersister persister) {
-        this.persister = persister;
-    }

     public List<UpdateListener> getListeners() {
         return updateListeners;
=======================================
--- /trunk/src/ca/sqlpower/architect/etl/kettle/KettleJob.java Mon Dec 21 11:04:05 2009 +++ /trunk/src/ca/sqlpower/architect/etl/kettle/KettleJob.java Wed Mar 17 13:09:48 2010
@@ -82,27 +82,6 @@
      */
     private static int spacing = 150;

-    /**
-     * The name of the Kettle job
-     */
-    private String jobName;
-
-    /**
-     * The name of the target schema
-     */
-    private String schemaName;
-
-    /**
- * The default join type for Kettle. The join types are stored as int as the values
-     * are in an array in Kettle.
-     */
-    private int kettleJoinType;
-
-    /**
-     * The path to store the Kettle job at
-     */
-    private String filePath;
-
     /**
* A list of tasks that an administrator or tech will have to do to the Kettle
      * job to make it run correctly.
@@ -115,15 +94,6 @@
      */
     private MonitorableImpl monitor;

-    /**
- * A flag that determines whether we will save the job to an xml file or a Kettle repository
-     */
-    private boolean savingToFile = true;
-
-    /**
- * The SPDataSource representation of the database with the Kettle repository we want to save to
-     */
-    private JDBCDataSource repository;

     /**
* The repository directory chooser that will select, or allow the user to select, the directory to save
@@ -136,6 +106,11 @@
      */
     private final ArchitectSession session;

+    /**
+     * Holds the settings for persistence to server.
+     */
+    private final KettleSettings settings;
+
public KettleJob(ArchitectSession session, KettleRepositoryDirectoryChooser chooser) {
         this(session);
         dirChooser = chooser;
@@ -143,9 +118,13 @@

     public KettleJob(ArchitectSession session) {
         super();
-        filePath = "";
-        tasksToDo = new ArrayList<String>();
         this.session = session;
+        if (session.getWorkspace() != null) {
+            settings = session.getWorkspace().getKettleSettings();
+        } else {
+            settings = new KettleSettings();
+        }
+        tasksToDo = new ArrayList<String>();
         monitor = new MonitorableImpl();
         dirChooser = new RootRepositoryDirectoryChooser();
     }
@@ -258,12 +237,12 @@
                 }

                 List<StepMeta> mergeSteps;
- mergeSteps = createMergeJoins(kettleJoinType, transMeta, inputSteps); + mergeSteps = createMergeJoins(settings.getJoinType(), transMeta, inputSteps);

                 TableOutputMeta tableOutputMeta = new TableOutputMeta();
                 tableOutputMeta.setDatabaseMeta(targetDatabaseMeta);
                 tableOutputMeta.setTablename(table.getName());
-                tableOutputMeta.setSchemaName(schemaName);
+                tableOutputMeta.setSchemaName(settings.getSchemaName());
StepMeta stepMeta = new StepMeta("TableOutput", "Output to " + table.getName(), tableOutputMeta);
                 stepMeta.setDraw(true);
stepMeta.setLocation((inputSteps.size()+1)*spacing, inputSteps.size()*spacing);
@@ -330,9 +309,9 @@
                 return;
             }

-            jm.setName(jobName);
-
-            if (savingToFile) {
+            jm.setName(settings.getJobName());
+
+            if (settings.isSavingToFile()) {
                 outputToXML(transformations, jm);
             } else {
                 jm.setDirectory(new RepositoryDirectory());
@@ -416,7 +395,7 @@
             trans.setFileName(getTransFilePath(trans.getName()));
         }

-        String fileName = filePath;
+        String fileName = settings.getFilePath();
         if (!fileName.toUpperCase().endsWith(".KJB")) {
             fileName += ".kjb";
         }
@@ -468,7 +447,7 @@
* The file location of the transformations is based on the location of the job.
      */
     String getTransFilePath(String transName) {
-        String parentPath = new File(filePath).getParentFile().getPath();
+ String parentPath = new File(settings.getFilePath()).getParentFile().getPath();
         logger.debug("Parent file path is " + parentPath);
return new File(parentPath, "transformation_for_table_" + transName + ".ktr").getPath();
     }
@@ -484,7 +463,7 @@
             // Pass the repository a connection straight as the Repository
             // connect method loads its own drivers and we don't want to
             // include them.
- repo.getDatabase().setConnection(repository.createConnection()); + repo.getDatabase().setConnection(settings.getRepository().createConnection());

             RepositoryDirectory directory;

@@ -593,12 +572,12 @@
      */
     Repository createRepository() {

- DatabaseMeta kettleDBMeta = KettleUtils.createDatabaseMeta(repository); + DatabaseMeta kettleDBMeta = KettleUtils.createDatabaseMeta(settings.getRepository());
         RepositoryMeta repoMeta = new RepositoryMeta("", "", kettleDBMeta);

- UserInfo userInfo = new UserInfo(repository.get(KettleOptions.KETTLE_REPOS_LOGIN_KEY),
-                repository.get(KettleOptions.KETTLE_REPOS_PASSWORD_KEY),
-                jobName, "", true, null);
+ UserInfo userInfo = new UserInfo(settings.getRepository().get(KettleOptions.KETTLE_REPOS_LOGIN_KEY), + settings.getRepository().get(KettleOptions.KETTLE_REPOS_PASSWORD_KEY),
+                settings.getJobName(), "", true, null);
LogWriter lw = LogWriter.getInstance(); // Repository constructor needs this for some reason

         Repository repo = new Repository(lw, repoMeta, userInfo);
@@ -660,28 +639,28 @@
     }

     public String getFilePath() {
-        return filePath;
+        return settings.getFilePath();
     }
     public void setFilePath(String filePath) {
-        this.filePath = filePath;
+        settings.setFilePath(filePath);
     }
     public String getJobName() {
-        return jobName;
+        return settings.getJobName();
     }
     public void setJobName(String jobName) {
-        this.jobName = jobName;
+       settings.setJobName(jobName);
     }
     public int getKettleJoinType() {
-        return kettleJoinType;
+        return settings.getJoinType();
     }
     public void setKettleJoinType(int kettleJoinType) {
-        this.kettleJoinType = kettleJoinType;
+        settings.setJoinType(kettleJoinType);
     }
     public String getSchemaName() {
-        return schemaName;
+        return settings.getSchemaName();
     }
     public void setSchemaName(String schemaName) {
-        this.schemaName = schemaName;
+        settings.setSchemaName(schemaName);
     }

     public List<String> getTasksToDo() {
@@ -717,14 +696,14 @@
     }

     public boolean isSavingToFile() {
-        return savingToFile;
+        return settings.isSavingToFile();
     }
     public void setSavingToFile(boolean savingToFile) {
-        this.savingToFile = savingToFile;
+        settings.setSavingToFile(savingToFile);
     }

     public void setRepository(JDBCDataSource source) {
-        this.repository = source;
+        settings.setRepository(source);
     }

public void setRepositoryDirectoryChooser(KettleRepositoryDirectoryChooser chooser) {
@@ -732,6 +711,6 @@
     }

     public SPDataSource getRepository() {
-        return repository;
+        return settings.getRepository();
     }
 }
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/DataMoverPanel.java Mon Mar 15 14:01:46 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/DataMoverPanel.java Wed Mar 17 13:09:48 2010
@@ -44,6 +44,7 @@
 import ca.sqlpower.architect.ddl.DDLGenerator;
 import ca.sqlpower.architect.ddl.DDLStatement;
 import ca.sqlpower.architect.ddl.DDLUtils;
+import ca.sqlpower.architect.etl.kettle.KettleSettings;
 import ca.sqlpower.architect.olap.OLAPRootObject;
import ca.sqlpower.architect.swingui.action.DatabaseConnectionManagerAction;
 import ca.sqlpower.architect.swingui.dbtree.DBTreeCellRenderer;
@@ -169,7 +170,7 @@
         try {
             if (treeRoot == null) {
                 treeRoot = new SQLObjectRoot();
- ArchitectProject treeProject = new ArchitectProject(treeRoot, new OLAPRootObject()); + ArchitectProject treeProject = new ArchitectProject(treeRoot, new OLAPRootObject(), new KettleSettings());
                 treeProject.setSession(session);
treeRoot.begin("Setting up database trees in data mover panel.");
             } else {
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/KettleJobPanel.java Fri Jan 15 15:02:04 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/KettleJobPanel.java Wed Mar 17 13:09:48 2010
@@ -352,12 +352,14 @@
     private void copySettingsToProject() {
         logger.debug("Saving settings to the project..."); //$NON-NLS-1$
         KettleJob settings = session.getKettleJob();
+        session.getWorkspace().begin("Saving kettle settings");
         settings.setJobName(nameField.getText());
         settings.setSchemaName(schemaName.getText());
         settings.setKettleJoinType(defaultJoinType.getSelectedIndex());
         settings.setFilePath(filePath.getText());
         settings.setRepository((JDBCDataSource)reposDB.getSelectedItem());
         settings.setSavingToFile(isSaveFile());
+        session.getWorkspace().commit();
     }

     public boolean hasUnsavedChanges() {

Reply via email to