-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from eroispaziali/ft/flows
Support for flow deactivation and deletion
- Loading branch information
Showing
28 changed files
with
1,909 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="src" path="src/test/java"/> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ target/classes/* | |
*.class | ||
test-report*.xml | ||
/target/ | ||
.idea* | ||
.DS_Store | ||
package.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.5 | ||
org.eclipse.jdt.core.compiler.source=1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,14 @@ It is built on top of [Apache Ant](http://ant.apache.org/), so it can be used in | |
* Execute Apex code | ||
* Run Apex tests (with XML reports) | ||
* Insert and delete records | ||
* Support for flow deactivation and deletion | ||
|
||
## Usage | ||
### Create a build file | ||
If you are not familiar with Ant and you need a template for your script you can copy the one below. | ||
```XML | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="forceflow-sample" xmlns:forceflow="antlib:com.spaceheroes"> | ||
<project name="forceflow-sample" xmlns:ff="antlib:com.spaceheroes"> | ||
|
||
<!-- | ||
This assumes forceflow.jar is copied | ||
|
@@ -35,57 +36,87 @@ If you are not familiar with Ant and you need a template for your script you can | |
### Execute Apex code | ||
You can execute an Apex script as follows. | ||
```XML | ||
<forceflow:apex username="..." password="..." serverurl="..."> | ||
<ff:apex username="..." password="..." serverurl="..."> | ||
<![CDATA[ | ||
List<Contact> cts = [SELECT id,Email FROM Contact WHERE (Email<>null AND (NOT Email LIKE '%.nospam'))]; | ||
for (Contact ct : cts) { | ||
ct.Email = ct.Email + '.nospam'; | ||
} | ||
update cts; | ||
]]> | ||
</forceflow:apex> | ||
</ff:apex> | ||
``` | ||
|
||
### Remote Site Settings | ||
Use this to create or update remote site settings. | ||
```XML | ||
<forceflow:remotesite name="Google_APIs" url="https://www.googleapis.com" disableProtocolSecurity="true" username="..." password="..." serverurl="..."> | ||
<ff:remotesite name="Google_APIs" url="https://www.googleapis.com" disableProtocolSecurity="true" username="..." password="..." serverurl="..."> | ||
Allows queries to the Google Maps API | ||
</forceflow:remotesite> | ||
</ff:remotesite> | ||
``` | ||
|
||
### Clear scheduled jobs | ||
Use this tag to abort all the jobs that are currently scheduled. | ||
```XML | ||
<forceflow:clearschedule username="..." password="..." serverurl="..." /> | ||
<ff:clearschedule username="..." password="..." serverurl="..." /> | ||
``` | ||
|
||
### Schedule an Apex job | ||
You can use this task to schedule the execution of a batch class. | ||
```XML | ||
<forceflow:scheduleapex username="..." password="..." serverurl="..." className="MySchedulableClass" cron="0 0 12 1/1 * ? *" /> | ||
<ff:scheduleapex username="..." password="..." serverurl="..." className="MySchedulableClass" cron="0 0 12 1/1 * ? *" /> | ||
``` | ||
|
||
### Insert a record | ||
Works with both objects and custom settings. | ||
```XML | ||
<forceflow:insert object="Contact" username="..." password="..." serverurl="..."> | ||
<ff:insert object="Contact" username="..." password="..." serverurl="..."> | ||
<property name="FirstName" value="Some"/> | ||
<property name="LastName" value="Dude"/> | ||
<property name="Email" value="[email protected]"/> | ||
</forceflow:insert> | ||
</ff:insert> | ||
``` | ||
|
||
### Delete all records | ||
You can delete all the records from an object or a custom settings. It's bulkified, so it works also with very large tables. | ||
```XML | ||
<forceflow:deleteall object="Contact" username="..." password="..." serverurl="..."/> | ||
<ff:deleteall object="Contact" username="..." password="..." serverurl="..."/> | ||
``` | ||
|
||
### Run all tests (with XML test report) | ||
Generates a full test report in the JUnit XML format (output file: _test-report.xml_). This report can be read by Atlassian Bamboo to [display test results of a build](https://confluence.atlassian.com/bamboo/viewing-test-results-for-a-build-289276936.html). | ||
```XML | ||
<forceflow:runtests username="..." password="..." serverurl="..." /> | ||
<ff:runtests username="..." password="..." serverurl="..." /> | ||
``` | ||
|
||
### Deactivate flows | ||
|
||
```XML | ||
<target name="deactivateFlows"> | ||
|
||
<delete dir="temp"/> | ||
|
||
<!-- retrieve existing flows --> | ||
<ff:createFlowRetrieveAllManifest destinationPath="temp/existing" /> | ||
<sf:retrieve | ||
username="${sf.username}" | ||
password="${sf.password}" | ||
serverurl="${sf.serverurl}" | ||
retrieveTarget="temp/existing" | ||
unpackaged="temp/existing/package.xml"/> | ||
|
||
<!-- create a manifest to inactivate all the flows, then deploy it --> | ||
<ff:createFlowInactivateManifest | ||
sourcePath="temp/existing" | ||
destinationPath="temp/inactivation" /> | ||
<sf:deploy | ||
username="${sf.username}" | ||
password="${sf.password}" | ||
serverurl="${sf.serverurl}" | ||
deployRoot="temp/inactivation" /> | ||
|
||
<delete dir="temp"/> | ||
</target> | ||
``` | ||
|
||
## License | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
machine: | ||
java: | ||
version: openjdk8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.spaceheroes.model; | ||
|
||
import java.io.File; | ||
import java.util.Objects; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class FlowFile { | ||
|
||
private File file; | ||
private String name; | ||
private Integer version; | ||
|
||
public FlowFile(File f) { | ||
this.file = Objects.requireNonNull(f); | ||
String srcFileNameNoExt = StringUtils.substringBeforeLast(f.getName(), "."); | ||
this.name = StringUtils.substringBeforeLast(srcFileNameNoExt, "-"); | ||
String flowNumber = StringUtils.substringAfterLast(srcFileNameNoExt, "-"); | ||
this.version = StringUtils.isNumeric(flowNumber) ? Integer.valueOf(flowNumber) : 1; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getFilename(Integer version) { | ||
String destFilename = | ||
(version>0) | ||
? String.format("%s-%d.flow", name, version) | ||
: String.format("%s.flow", name) ; | ||
return destFilename; | ||
} | ||
|
||
public String getFlowName(Integer version) { | ||
String destFilename = | ||
(version>0) | ||
? String.format("%s-%d", name, version) | ||
: String.format("%s", name) ; | ||
return destFilename; | ||
} | ||
|
||
public String getFilenameCurrentVersion() { | ||
return getFilename(version); | ||
} | ||
|
||
public String getFilenameNextVersion() { | ||
return getFilename(version+1); | ||
} | ||
|
||
public String getFlowNameCurrentVersion() { | ||
return getFlowName(version); | ||
} | ||
|
||
public String getFlowNameNextVersion() { | ||
return getFlowName(version+1); | ||
} | ||
|
||
public Integer getVersion() { | ||
return version; | ||
} | ||
|
||
public File getFile() { | ||
return file; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/spaceheroes/task/local/CreateFlowDeleteManifestTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.spaceheroes.task.local; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Task; | ||
|
||
import com.spaceheroes.util.FlowUtils; | ||
|
||
public class CreateFlowDeleteManifestTask extends Task { | ||
|
||
private String sourcePath; | ||
private String destinationPath; | ||
|
||
@Override | ||
public void execute() throws BuildException { | ||
try { | ||
FlowUtils.createFlowDeletionPack(sourcePath, destinationPath); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
throw new BuildException(e); | ||
} | ||
super.execute(); | ||
} | ||
|
||
public String getDestinationPath() { | ||
return destinationPath; | ||
} | ||
|
||
public void setDestinationPath(String destinationPath) { | ||
this.destinationPath = destinationPath; | ||
} | ||
|
||
public String getSourcePath() { | ||
return sourcePath; | ||
} | ||
|
||
public void setSourcePath(String sourcePath) { | ||
this.sourcePath = sourcePath; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/spaceheroes/task/local/CreateFlowInactivateManifestTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.spaceheroes.task.local; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Task; | ||
|
||
import com.spaceheroes.util.FlowUtils; | ||
|
||
public class CreateFlowInactivateManifestTask extends Task { | ||
|
||
private String sourcePath; | ||
private String destinationPath; | ||
private Boolean destructiveChanges = Boolean.FALSE; | ||
|
||
@Override | ||
public void execute() throws BuildException { | ||
try { | ||
FlowUtils.createFlowInactivation(sourcePath, destinationPath, destructiveChanges); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
throw new BuildException(e); | ||
} | ||
super.execute(); | ||
} | ||
|
||
public String getDestinationPath() { | ||
return destinationPath; | ||
} | ||
|
||
public void setDestinationPath(String destinationPath) { | ||
this.destinationPath = destinationPath; | ||
} | ||
|
||
public String getSourcePath() { | ||
return sourcePath; | ||
} | ||
|
||
public void setSourcePath(String sourcePath) { | ||
this.sourcePath = sourcePath; | ||
} | ||
|
||
public Boolean getDestructiveChanges() { | ||
return destructiveChanges; | ||
} | ||
|
||
public void setDestructiveChanges(Boolean destructiveChanges) { | ||
this.destructiveChanges = destructiveChanges; | ||
} | ||
|
||
} |
Oops, something went wrong.