generated from jogetoss/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef08422
commit 1bac177
Showing
5 changed files
with
214 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target/ | ||
*.class |
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,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.joget.marketplace</groupId> | ||
<artifactId>formatnumber-hash</artifactId> | ||
<packaging>bundle</packaging> | ||
<version>8.0.0</version> | ||
<name>formatnumber-hash</name> | ||
<url>http://www.joget.org</url> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.0.2</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.4.3</version> | ||
<configuration> | ||
<skipTests>false</skipTests> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>integration-test</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<skipTests>false</skipTests> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
<!-- Change package and plugin class here --> | ||
<Export-Package>org.joget.marketplace</Export-Package> | ||
<Private-Package>org.joget.marketplace.*</Private-Package> | ||
<Bundle-Activator>org.joget.marketplace.Activator</Bundle-Activator> | ||
<Import-Package>!*,org.joget.report.dao,org.joget.report.model,org.joget.report.service,org.joget.commons.util,org.joget.plugin.base,org.joget.plugin.property.model,org.joget.plugin.property.service,org.joget.directory.model,org.joget.directory.model.service,org.joget.directory.dao,org.joget.workflow.model,org.joget.workflow.model.dao,org.joget.workflow.model.service,org.joget.workflow.util,org.joget.apps.app.dao,org.joget.apps.app.lib,org.joget.apps.app.model,org.joget.apps.app.service,org.joget.apps.datalist.lib,org.joget.apps.datalist.model,org.joget.apps.datalist.service,org.joget.apps.form.lib,org.joget.apps.form.dao,org.joget.apps.form.model,org.joget.apps.form.service,org.joget.apps.list.service,org.joget.apps.userview.lib,org.joget.apps.userview.model,org.joget.apps.userview.service,org.joget.apps.workflow.lib,javax.servlet,javax.servlet.http,org.osgi.framework;version="1.3.0"</Import-Package> | ||
<!-- End change package and plugin class here --> | ||
<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency> | ||
<Embed-Transitive>true</Embed-Transitive> | ||
<Embed-Directory>dependency</Embed-Directory> | ||
<Embed-StripGroup>true</Embed-StripGroup> | ||
<DynamicImport-Package>*</DynamicImport-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.4</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.joget</groupId> | ||
<artifactId>wflow-core</artifactId> | ||
<version>8.0-SNAPSHOT</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- Change plugin specific dependencies here --> | ||
|
||
<!-- End change plugin specific dependencies here --> | ||
</dependencies> | ||
<distributionManagement> | ||
<repository> | ||
<id>internal</id> | ||
<url>https://dev.joget.org/archiva/repository/internal</url> | ||
</repository> | ||
<snapshotRepository> | ||
<id>snapshots</id> | ||
<url>https://dev.joget.org/archiva/repository/snapshots</url> | ||
</snapshotRepository> | ||
</distributionManagement> | ||
</project> |
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,25 @@ | ||
package org.joget.marketplace; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import org.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.framework.ServiceRegistration; | ||
|
||
public class Activator implements BundleActivator { | ||
|
||
protected Collection<ServiceRegistration> registrationList; | ||
|
||
public void start(BundleContext context) { | ||
registrationList = new ArrayList<ServiceRegistration>(); | ||
|
||
//Register plugin here | ||
registrationList.add(context.registerService(FormatNumberHashVariable.class.getName(), new FormatNumberHashVariable(), null)); | ||
} | ||
|
||
public void stop(BundleContext context) { | ||
for (ServiceRegistration registration : registrationList) { | ||
registration.unregister(); | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/org/joget/marketplace/FormatNumberHashVariable.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,83 @@ | ||
package org.joget.marketplace; | ||
|
||
import java.text.DecimalFormat; | ||
import java.text.DecimalFormatSymbols; | ||
import org.joget.apps.app.model.DefaultHashVariablePlugin; | ||
|
||
public class FormatNumberHashVariable extends DefaultHashVariablePlugin { | ||
|
||
@Override | ||
public String processHashVariable(String variableKey) { | ||
String formattedNumber = ""; | ||
DecimalFormat decimalFormat = new DecimalFormat(); | ||
DecimalFormatSymbols customSymbols = new DecimalFormatSymbols(); | ||
if (variableKey.indexOf("[") == -1) { | ||
return variableKey; | ||
} else { | ||
String numberString = variableKey.substring(0, !variableKey.contains("[") ? variableKey.length() - 1 : variableKey.indexOf("[")); | ||
String options = variableKey.substring(variableKey.indexOf("[")); | ||
int decimalPlaces = 0; | ||
options = options.replaceAll("\\[|\\]", ""); | ||
String[] pieces = options.split("&"); | ||
for (String opt : pieces) { | ||
if (opt.contains("decimal=")) { | ||
try { | ||
decimalPlaces = Integer.parseInt(opt.substring(opt.indexOf("=") + 1)); | ||
decimalFormat.setMaximumFractionDigits(decimalPlaces); | ||
decimalFormat.setMinimumFractionDigits(decimalPlaces); | ||
customSymbols.setGroupingSeparator('\0'); | ||
decimalFormat.setDecimalFormatSymbols(customSymbols); | ||
} catch (NumberFormatException e) { | ||
|
||
} | ||
|
||
} else if (opt.contains("thousandSeparator=")) { | ||
String separator = opt.substring(opt.indexOf("=") + 1); | ||
if (separator != null && !separator.isEmpty()) { | ||
customSymbols.setGroupingSeparator(separator.charAt(0)); | ||
decimalFormat.setDecimalFormatSymbols(customSymbols); | ||
} | ||
} | ||
} | ||
formattedNumber = numberString; | ||
formattedNumber = decimalFormat.format(Double.parseDouble(formattedNumber)); | ||
} | ||
return formattedNumber; | ||
} | ||
|
||
@Override | ||
public String getPrefix() { | ||
return "formatNumber"; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Format Number Hash Variable"; | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return "8.0.0"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Format Number Hash Variable"; | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return "Format Number Hash Variable"; | ||
} | ||
|
||
@Override | ||
public String getClassName() { | ||
return this.getClass().getName(); | ||
} | ||
|
||
@Override | ||
public String getPropertyOptions() { | ||
return ""; | ||
} | ||
|
||
} |