View Javadoc

1   /*******************************************************************************
2    * Copyright (c) 2009 Ordina and committers to Mod4j
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *     Ordina - initial implementation
10   *******************************************************************************/
11  package org.mod4j.dslcommon.generator.helpers;
12  
13  import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent;
14  import org.eclipse.emf.mwe.core.WorkflowContext;
15  import org.eclipse.emf.mwe.core.issues.Issues;
16  import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
17  
18  /* 
19   * Workflow component to read a properties files
20   * Referenced from workflow (*.oaw) files.
21   */
22  public class PropertiesWorkflowComponent extends AbstractWorkflowComponent {
23  
24      /**
25       * Then calling MyWorkflowComponent the invoke method is called. We use it, to instance the model and apply it to a
26       * modelslot, so it can be used later by the generator component.
27       * 
28       * @see org.openarchitectureware.workflow.WorkflowComponent#invoke(org.openarchitectureware.workflow.WorkflowContext,
29       *      org.openarchitectureware.workflow.monitor.ProgressMonitor, org.openarchitectureware.workflow.issues.Issues)
30       */
31  	@Override
32      public void invokeInternal(WorkflowContext wfCxt, ProgressMonitor arg1, Issues arg2) {
33          System.err.println("PropertiesWorkflowComponent: Found property slot [" + getPropertyFile() + "]");
34          ProjectProperties.setPropertiesFile(getPropertyFile());
35          ProjectProperties.setWorkDir(getWorkDir());
36          ProjectProperties.setProject(getProject());
37      }
38  
39      public void checkConfiguration(final Issues issues) {
40          if (propertyFile == null)
41              issues.addError(this, "propertyFile not specified.");
42      }
43  
44      // capture the value of the <propertyFileSlot> slot in the workflow
45      public String propertyFile;
46  
47      protected String getPropertyFile() {
48          return propertyFile;
49      }
50  
51      public void setPropertyFile(final String outlet) {
52          this.propertyFile = outlet;
53      }
54  
55      // capture the value of the <workDir> slot in the workflow
56      public String workDir;
57  
58      protected String getWorkDir() {
59          return workDir;
60      }
61  
62      public void setWorkDir(final String workDir) {
63          this.workDir = workDir;
64      }
65  
66      // capture the value of the <project> slot in the workflow
67      public String project;
68  
69      protected String getProject() {
70          return project;
71      }
72  
73      public void setProject(final String project) {
74          this.project = project;
75      }
76  
77  }