update to current development status
diff --git a/jenkins.build.config.xml b/jenkins.build.config.xml
index 9c0ca5f..a0d32bc 100644
--- a/jenkins.build.config.xml
+++ b/jenkins.build.config.xml
@@ -16,6 +16,7 @@
<jenkins.build.dependencies>
<jenkins.build.dependency>org.eclipse.osbp.dsl</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.ecview.core</jenkins.build.dependency>
+ <jenkins.build.dependency>org.eclipse.osbp.jpa.services</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.preferences</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.ui.api</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.utils.ui</jenkins.build.dependency>
diff --git a/org.eclipse.osbp.abstractstatemachine.feature/.gitignore b/org.eclipse.osbp.abstractstatemachine.feature/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/org.eclipse.osbp.abstractstatemachine.feature/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/org.eclipse.osbp.abstractstatemachine.feature/META-INF/git.properties b/org.eclipse.osbp.abstractstatemachine.feature/META-INF/git.properties
deleted file mode 100644
index 8aae781..0000000
--- a/org.eclipse.osbp.abstractstatemachine.feature/META-INF/git.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-#Generated by Git-Commit-Id-Plugin
-#Thu Jan 26 12:21:40 CET 2017
-git.remote.origin.url=ssh\://compex@10.1.13.14/osbpgit/org.eclipse.osbp.abstractstatemachine.git
-git.closest.tag.name=Version1-2017-01-23-13-48-06
-git.commit.id.describe-short=Version1-2017-01-23-13-48-06-5-dirty
-git.commit.time=26.01.2017 @ 10\:35\:46 MEZ
-git.commit.message.full=relocated statemachine to abstractstatemachine
-git.commit.message.short=relocated statemachine to abstractstatemachine
-git.commit.id.abbrev=adab955
-git.branch=development
-git.closest.tag.commit.count=5
-git.commit.id.describe=Version1-2017-01-23-13-48-06-5-gadab955-dirty
-git.commit.id=adab9550996ab4b5169ce2651f2e7f672a353c54
-git.tags=
diff --git a/org.eclipse.osbp.abstractstatemachine.feature/feature.xml b/org.eclipse.osbp.abstractstatemachine.feature/feature.xml
index f6087a8..347e108 100644
--- a/org.eclipse.osbp.abstractstatemachine.feature/feature.xml
+++ b/org.eclipse.osbp.abstractstatemachine.feature/feature.xml
@@ -3,7 +3,8 @@
id="org.eclipse.osbp.abstractstatemachine.feature"
label="%featureName"
version="0.9.0.qualifier"
- provider-name="%providerName">
+ provider-name="%providerName"
+ plugin="org.eclipse.osbp.abstractstatemachine">
<description>
%description
diff --git a/org.eclipse.osbp.abstractstatemachine/.classpath b/org.eclipse.osbp.abstractstatemachine/.classpath
new file mode 100644
index 0000000..cf36b56
--- /dev/null
+++ b/org.eclipse.osbp.abstractstatemachine/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.osbp.abstractstatemachine/.gitignore b/org.eclipse.osbp.abstractstatemachine/.gitignore
new file mode 100644
index 0000000..bb3b4c8
--- /dev/null
+++ b/org.eclipse.osbp.abstractstatemachine/.gitignore
@@ -0,0 +1,3 @@
+/bin/
+/target/
+**/git.properties
\ No newline at end of file
diff --git a/org.eclipse.osbp.abstractstatemachine/META-INF/MANIFEST.MF b/org.eclipse.osbp.abstractstatemachine/META-INF/MANIFEST.MF
index 053b8e3..14c1dee 100644
--- a/org.eclipse.osbp.abstractstatemachine/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.abstractstatemachine/META-INF/MANIFEST.MF
@@ -6,18 +6,22 @@
Bundle-Vendor: Eclipse OSBP
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
-Require-Bundle: org.eclipse.osbp.dsl.dto.lib;bundle-version="0.9.0",
- org.eclipse.osbp.dsl.datatype.lib;bundle-version="0.9.0",
- org.eclipse.osbp.ecview.core.common;bundle-version="0.9.0",
+Require-Bundle: org.eclipse.osbp.dsl.dto.lib;bundle-version="[0.9.0,0.10.0)",
+ org.eclipse.osbp.dsl.datatype.lib;bundle-version="[0.9.0,0.10.0)",
+ org.eclipse.osbp.ecview.core.common;bundle-version="[0.9.0,0.10.0)",
org.eclipse.core.runtime;bundle-version="3.10.0",
org.slf4j.api;bundle-version="1.7.2",
- org.eclipse.osbp.fork.jpos;bundle-version="1.14.0",
- com.vaadin.server;bundle-version="7.5.7",
- org.eclipse.osbp.dsl.dto.xtext,
- org.eclipse.osgi.services;bundle-version="3.4.0"
+ com.vaadin.server;bundle-version="[7.7.6,7.8.0)",
+ org.eclipse.osbp.dsl.dto.xtext;bundle-version="[0.9.0,0.10.0)",
+ org.eclipse.osgi.services;bundle-version="3.5.100",
+ com.vaadin.shared;bundle-version="[7.7.6,7.8.0)",
+ org.eclipse.osbp.fork.jpos;bundle-version="[1.14.0,1.15.0)",
+ org.eclipse.osbp.jpa.services;bundle-version="0.9.0"
Import-Package: javax.servlet;version="2.6.0",
javax.servlet.http;version="2.6.0",
+ org.eclipse.e4.core.contexts,
org.eclipse.osbp.preferences;version="0.9.0",
+ org.eclipse.osbp.ui.api.customfields;version="0.9.0",
org.eclipse.osbp.ui.api.datamart;version="0.9.0",
org.eclipse.osbp.ui.api.message;version="0.9.0",
org.eclipse.osbp.ui.api.metadata;version="0.9.0",
diff --git a/org.eclipse.osbp.abstractstatemachine/OSGI-INF/org.eclipse.osbp.abstractstatemachine.POSServiceBinder.xml b/org.eclipse.osbp.abstractstatemachine/OSGI-INF/org.eclipse.osbp.abstractstatemachine.POSServiceBinder.xml
index 6352f72..f8c09dc 100644
--- a/org.eclipse.osbp.abstractstatemachine/OSGI-INF/org.eclipse.osbp.abstractstatemachine.POSServiceBinder.xml
+++ b/org.eclipse.osbp.abstractstatemachine/OSGI-INF/org.eclipse.osbp.abstractstatemachine.POSServiceBinder.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osbp.abstractstatemachine.POSServiceBinder">
<reference bind="bindPOSService" cardinality="0..1" interface="org.eclipse.osbp.ui.api.pos.IPOSService" name="POSService" policy="dynamic" unbind="unbindPOSService"/>
+ <reference bind="bindSessionManager" cardinality="1..1" interface="org.eclipse.osbp.runtime.common.session.ISessionManager" name="SessionManager" policy="static" unbind="unbindSessionManager"/>
+ <reference bind="bindSignatureService" cardinality="0..1" interface="org.eclipse.osbp.ui.api.pos.ISignatureService" name="SignatureService" policy="static" unbind="unbindSignatureService"/>
<implementation class="org.eclipse.osbp.abstractstatemachine.POSServiceBinder"/>
</scr:component>
\ No newline at end of file
diff --git a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractDataProvider.java b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractDataProvider.java
index 30ea08c..4f16f6f 100644
--- a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractDataProvider.java
+++ b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractDataProvider.java
@@ -20,231 +20,200 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Stack;
import org.eclipse.osbp.dsl.common.datatypes.IDto;
import org.eclipse.osbp.dsl.dto.lib.impl.DtoServiceAccess;
-import org.eclipse.osbp.dsl.dto.lib.services.IDTOService;
-import org.eclipse.osbp.dsl.dto.lib.services.Query;
-import org.eclipse.osbp.dsl.dto.lib.services.filters.LCompare;
-import org.eclipse.osbp.dsl.semantic.dto.LDto;
-import org.eclipse.osbp.ecview.core.common.beans.ISlot;
+import org.eclipse.osbp.jpa.services.Query;
+import org.eclipse.osbp.jpa.services.filters.LCompare;
+import org.eclipse.osbp.jpa.services.filters.LIsNull;
+import org.eclipse.osbp.jpa.services.filters.LLike;
+import org.eclipse.osbp.jpa.services.filters.LNot;
+import org.eclipse.osbp.runtime.common.filter.IDTOService;
+import org.eclipse.osbp.runtime.common.filter.IQuery;
import org.eclipse.osbp.ui.api.statemachine.IDataProvider;
import org.eclipse.osbp.ui.api.statemachine.IStateMachine;
@SuppressWarnings("restriction")
-public abstract class AbstractDataProvider extends
- AbstractStateMachineParticipant implements IDataProvider,
- IDataProvider.Provider {
+public abstract class AbstractDataProvider extends AbstractStateMachineParticipant
+ implements IDataProvider, IDataProvider.Provider {
protected Map<String, IDTOService<? extends IDto>> dtoServices = new HashMap<>();
protected boolean ready;
-
+
@Override
public void setStatemachine(IStateMachine statemachine) {
super.setStatemachine(statemachine);
statemachine.registerDataProvider(this);
}
- @Override
- public void initDatasource(String dtoAlias) {
- ISlot slot = viewContext.getBeanSlot(dtoAlias);
- if(slot == null) {
- LOGGER.error("cannot find alias "+dtoAlias+" in UI model. DTO therefore not accessible for DataProviders");
- return;
- }
- if (IDto.class.isAssignableFrom(slot.getValueType())) {
- @SuppressWarnings("unchecked")
- Class<IDto> type = (Class<IDto>) slot.getValueType();
- dtoServices.put(type.getSimpleName(),
- DtoServiceAccess.getService(type));
- } else {
- LOGGER.error(dtoAlias+" is not bound as DTO from UI model and therefore not accessible for DataProviders");
- }
- }
-
- public void initDatasourceFromDto(String dtoName) {
- for(String slotName:viewContext.getValueBeans().keySet()) {
- ISlot slot = viewContext.getBeanSlot(slotName);
- if (IDto.class.isAssignableFrom(slot.getValueType())) {
- @SuppressWarnings("unchecked")
- Class<IDto> type = (Class<IDto>) slot.getValueType();
- if(dtoName.equals(type.getSimpleName())) {
- dtoServices.put(type.getSimpleName(),
- DtoServiceAccess.getService(type));
- return;
- }
- }
- }
- LOGGER.error(dtoName+" is not bound from UI model and therefore not accessible for DataProviders");
+ @Override
+ public void addDatasource(String dtoAlias, Class<?> dtoServiceClass) {
+ @SuppressWarnings("unchecked")
+ Class<IDto> type = (Class<IDto>)dtoServiceClass;
+ dtoServices.put(dtoAlias, DtoServiceAccess.getService(type));
}
@Override
- public Boolean find(IDataProvider.Provider listener, String dtoName,
- String fieldName, Object search) {
- return find(listener, dtoName, new Query(new LCompare.Equal(fieldName, search)));
+ public Boolean find(IDataProvider.Provider listener, String dtoAlias, String fieldName, Object search) {
+ return find(listener, dtoAlias, new Query(new LCompare.Equal(fieldName, search)));
}
-
+
@Override
- public Boolean find(IDataProvider.Provider listener, String dtoName, Query query) {
- Collection<? extends IDto> results = findDtoInstances(dtoName, query);
- if (results == null) {
- return false;
- }
+ public Boolean find(IDataProvider.Provider listener, String dtoAlias, IQuery query) {
+ Collection<? extends IDto> results = findDtoInstances(dtoAlias, query);
if (results.size() > 1) {
- LOGGER.error("find for " + dtoName
- + " returned multiple values - first value is used");
+ LOGGER.error("find for {} returned multiple values - first value is used", dtoAlias);
}
if (results.isEmpty()) {
- LOGGER.error("find for " + dtoName + " returned no values");
+ LOGGER.error("find for {} returned no values", dtoAlias);
}
try {
- Method method = setter(listener, dtoName, IDto.class);
- if(method == null) {
- return null;
+ Method method = setter(listener, dtoAlias, IDto.class, 0);
+ if (method == null) {
+ return false;
}
if (results.isEmpty()) {
method.invoke(listener, (IDto) null);
+ return false;
} else {
method.invoke(listener, (IDto) results.iterator().next());
}
return true;
- } catch (IllegalAccessException
- | IllegalArgumentException | InvocationTargetException e) {
- System.out.println(e);
- return null;
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ LOGGER.error("{}", e);
+ return false;
}
}
- protected Collection<? extends IDto> findDtoInstances(String dtoName, Query query) {
- if (!dtoServices.containsKey(dtoName)) {
- LOGGER.error(dtoName + " was not bound from ui model");
- return null;
+ @Override
+ public Collection<? extends IDto> findAll(String dtoAlias, IQuery query) {
+ return findDtoInstances(dtoAlias, query);
+ }
+
+ @Override
+ public Collection<? extends IDto> findAll(String dtoAlias, String fieldName, Object search) {
+ if(search instanceof String) {
+ if(((String)search).equalsIgnoreCase("[isnotnull]")) {
+ return findDtoInstances(dtoAlias, new Query(new LNot(new LIsNull(fieldName))));
+ }
+ if(((String)search).equalsIgnoreCase("[isnull]")) {
+ return findDtoInstances(dtoAlias, new Query(new LIsNull(fieldName)));
+ }
+ if(((String)search).contains("%") || ((String)search).contains("_")) {
+ return findDtoInstances(dtoAlias, new Query(new LLike(fieldName, (String) search)));
+ }
}
- IDTOService<? extends IDto> dtoService = dtoServices.get(dtoName);
+ return findDtoInstances(dtoAlias, new Query(new LCompare.Equal(fieldName, search)));
+ }
+
+ @Override
+ public Collection<? extends IDto> findAll(String dtoAlias, String fieldName) {
+ return findDtoInstances(dtoAlias, new Query());
+ }
+
+ protected Collection<? extends IDto> findDtoInstances(String dtoAlias, IQuery query) {
+ if (!dtoServices.containsKey(dtoAlias)) {
+ LOGGER.error("{} was not bound from ui model", dtoAlias);
+ return Collections.emptyList();
+ }
+ IDTOService<? extends IDto> dtoService = dtoServices.get(dtoAlias);
if (dtoService == null) {
- LOGGER.error(dtoName + " has no service registrated");
- return null;
+ LOGGER.error("{} has no service registrated", dtoAlias);
+ return Collections.emptyList();
}
- Collection<? extends IDto> results;
try {
- results = dtoService.find(query);
- if (results.size() > 1) {
- LOGGER.error("find for " + dtoName
- + " returned multiple values - first value is used");
- }
- if (results.isEmpty()) {
- LOGGER.error("find for " + dtoName + " returned no values");
- return null;
- }
- return results;
+ return dtoService.find(query);
} catch (Exception e) {
LOGGER.error("{}", e);
}
- return null;
+ return Collections.emptyList();
}
- @Override
- public Boolean operation(IDataProvider.Provider listener, String name,
- Stack<Object> parameter) {
- try {
- Class<?> clz = listener.getClass();
- try {
- BeanInfo info = Introspector.getBeanInfo(clz);
- for (MethodDescriptor desc : info.getMethodDescriptors()) {
- if (desc.getName().equalsIgnoreCase(name)) {
- Method method = desc.getMethod();
- return (Boolean) method.invoke(listener, parameter);
- }
- }
- } catch (IntrospectionException e) {
- LOGGER.error("{}", e);
- }
- return null;
- } catch (IllegalAccessException
- | IllegalArgumentException | InvocationTargetException e) {
- return null;
- }
- }
-
protected Method dispatchMethod(Provider listener, String methodName) {
try {
Class<?> clz = listener.getClass();
- try {
- BeanInfo info = Introspector.getBeanInfo(clz);
- for (MethodDescriptor desc : info.getMethodDescriptors()) {
- if (desc.getName().equalsIgnoreCase(methodName)) {
- return desc.getMethod();
- }
+ BeanInfo info = Introspector.getBeanInfo(clz);
+ for (MethodDescriptor desc : info.getMethodDescriptors()) {
+ if (desc.getName().equalsIgnoreCase(methodName)) {
+ return desc.getMethod();
}
- } catch (IntrospectionException e) {
- LOGGER.error("{}", e);
}
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException | IntrospectionException e) {
LOGGER.error("{}", e);
}
return null;
}
-
+
@Override
- public void addTo(Provider listener, String dtoName, String listName, IDto dto) {
- Method method = dispatchMethod(listener, "addTo"+dtoName+listName);
- if(method != null) {
+ public void addTo(Provider listener, String dtoAlias, String listName, IDto dto) {
+ Method method = dispatchMethod(listener, "addTo" + dtoAlias + listName);
+ if (method != null) {
try {
method.invoke(listener, dto);
- } catch (IllegalAccessException | IllegalArgumentException
- | InvocationTargetException e) {
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.error("{}", e);
}
} else {
- LOGGER.error("method addTo"+dtoName+listName+" not generated");
- }
- }
-
- @Override
- public void removeFrom(Provider listener, String dtoName, String listName, IDto dto) {
- Method method = dispatchMethod(listener, "removeFrom"+dtoName+listName);
- if(method != null) {
- try {
- method.invoke(listener, dto);
- } catch (IllegalAccessException | IllegalArgumentException
- | InvocationTargetException e) {
- LOGGER.error("{}", e);
- }
- } else {
- LOGGER.error("method removeFrom"+dtoName+listName+" not generated");
+ LOGGER.error("method addTo%s%s not generated", dtoAlias, listName);
}
}
@Override
- public void update(Provider listener, String dtoName, IDto dto) {
- Method method = dispatchMethod(listener, "update"+dtoName);
- if(method != null) {
+ public void removeFrom(Provider listener, String dtoAlias, String listName, IDto dto) {
+ Method method = dispatchMethod(listener, "removeFrom" + dtoAlias + listName);
+ if (method != null) {
try {
method.invoke(listener, dto);
- } catch (IllegalAccessException | IllegalArgumentException
- | InvocationTargetException e) {
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.error("{}", e);
}
} else {
- LOGGER.error("method update"+dtoName+" not generated");
+ LOGGER.error("method removeFrom%s%s not generated", dtoAlias, listName);
}
}
@Override
- public void delete(Provider listener, String dtoName, IDto dto) {
- Method method = dispatchMethod(listener, "delete"+dtoName);
- if(method != null) {
+ public void update(Provider listener, String dtoAlias, IDto dto) {
+ Method method = dispatchMethod(listener, "update" + dtoAlias);
+ if (method != null) {
try {
method.invoke(listener, dto);
- } catch (IllegalAccessException | IllegalArgumentException
- | InvocationTargetException e) {
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.error("{}", e);
}
} else {
- LOGGER.error("delete update"+dtoName+" not generated");
+ LOGGER.error("method update%s not generated", dtoAlias);
+ }
+ }
+
+ @Override
+ public void reload(Provider listener, String dtoAlias, IDto dto) {
+ Method method = dispatchMethod(listener, "reload" + dtoAlias);
+ if (method != null) {
+ try {
+ method.invoke(listener, dto);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ LOGGER.error("{}", e);
+ }
+ } else {
+ LOGGER.error("method reload%s not generated", dtoAlias);
+ }
+ }
+
+ @Override
+ public void delete(Provider listener, String dtoAlias, IDto dto) {
+ Method method = dispatchMethod(listener, "delete" + dtoAlias);
+ if (method != null) {
+ try {
+ method.invoke(listener, dto);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ LOGGER.error("{}", e);
+ }
+ } else {
+ LOGGER.error("delete update%s not generated", dtoAlias);
}
}
}
diff --git a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractEventSource.java b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractEventSource.java
index edbc781..20a366e 100644
--- a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractEventSource.java
+++ b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractEventSource.java
@@ -11,7 +11,7 @@
* Loetz GmbH & Co. KG
*
*/
- package org.eclipse.osbp.abstractstatemachine;
+package org.eclipse.osbp.abstractstatemachine;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
diff --git a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractPeripheralService.java b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractPeripheralService.java
index 1ab989e..5edf050 100644
--- a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractPeripheralService.java
+++ b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractPeripheralService.java
@@ -13,15 +13,27 @@
*/
package org.eclipse.osbp.abstractstatemachine;
+import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Enumeration;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.Set;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.osbp.preferences.ProductConfiguration;
+import org.eclipse.osbp.ui.api.message.MessageEvent;
+import org.eclipse.osbp.ui.api.message.MessageEvent.EventType;
+import org.eclipse.osbp.ui.api.pos.ISignatureEvent;
+import org.eclipse.osbp.ui.api.pos.ISignatureListener;
+import org.eclipse.osbp.ui.api.pos.IZVTTransactionData;
+import org.eclipse.osbp.ui.api.pos.PenData;
+import org.eclipse.osbp.ui.api.statemachine.IPeripheral;
+import org.eclipse.osbp.ui.api.statemachine.IStateMachine;
+import org.osgi.framework.FrameworkUtil;
import jpos.BaseControl;
import jpos.CashDrawer;
@@ -34,9 +46,7 @@
import jpos.POSPrinter;
import jpos.POSPrinterConst;
import jpos.POSPrinterControl114;
-import jpos.config.JposEntry.Prop;
import jpos.config.JposEntryRegistry;
-import jpos.config.simple.SimpleEntry;
import jpos.epson.EpsonLineDisplayConst;
import jpos.epson.EpsonPOSPrinterConst;
import jpos.events.ErrorEvent;
@@ -50,31 +60,36 @@
import jpos.util.JposProperties;
import jpos.util.JposPropertiesConst;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.osbp.preferences.ProductConfiguration;
-import org.eclipse.osbp.ui.api.datamart.IDataMart;
-import org.eclipse.osbp.ui.api.message.MessageEvent;
-import org.eclipse.osbp.ui.api.message.MessageEvent.EventType;
-import org.eclipse.osbp.ui.api.pos.IZVTTransactionData;
-import org.eclipse.osbp.ui.api.statemachine.IPeripheral;
-import org.eclipse.osbp.ui.api.statemachine.IStateMachine;
-import org.osgi.framework.FrameworkUtil;
-
/**
- * PeripheralService is a bridge between javaPOS and the state machine participant.
+ * PeripheralService is a bridge between javaPOS and the state machine
+ * participant.
*/
public abstract class AbstractPeripheralService extends AbstractStateMachineParticipant
- implements IPeripheral, IPeripheral.Command, StatusUpdateListener,
- ErrorListener, OutputCompleteListener {
+ implements IPeripheral, IPeripheral.Command, StatusUpdateListener, ErrorListener, OutputCompleteListener, ISignatureListener {
/** The devices. */
protected Map<String, BaseControl> devices = new HashMap<>();
-
+
+ /** The slip notifications enabled. */
private boolean slipNotificationsEnabled = false;
- private boolean devicesInit = false;
- private int windowsCreated = 0;
- private String ptIP;
- private Integer ptPort;
+
+ /** The windows created. */
+ protected int windowsCreated = 0;
+
+ /** The pt IP. */
+ protected String ptIP;
+
+ /** The pt port. */
+ protected Integer ptPort;
+
+ /** The props. */
+ protected JposEntryRegistry props;
+
+ /** is init done correctly? */
+ protected boolean initDone = false;
+
+ private List<PenData> penData = new ArrayList<>();
+
/*
* (non-Javadoc)
*
@@ -86,7 +101,7 @@
public void setStatemachine(IStateMachine statemachine) {
super.setStatemachine(statemachine);
statemachine.registerPeripheral(this);
- if(POSServiceBinder.getPosService() != null) {
+ if (POSServiceBinder.getPosService() != null) {
POSServiceBinder.getPosService().setStatemachine(statemachine);
}
}
@@ -98,171 +113,84 @@
*/
@Override
public void init() {
- initDevices();
+ LOGGER.debug("Library path=" + System.getProperty("java.library.path"));
+ // load all names of configured devices, instantiate and cache it
+ String configFile = ProductConfiguration.getJavaPosConfiguration();
+ if (configFile == null || configFile.length() == 0) {
+ LOGGER.debug("POS setupfile is not registered in product preferences");
+ return;
+ }
+ try {
+ new URL(configFile);
+ System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_URL_PROP_NAME, configFile);
+ } catch (MalformedURLException e) {
+ System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, configFile);
+ }
+ System.setProperty(JposPropertiesConst.JPOS_REG_POPULATOR_CLASS_PROP_NAME,
+ "jpos.config.simple.xml.SimpleXmlRegPopulator");
+ System.setProperty(JposPropertiesConst.JPOS_SERVICE_MANAGER_CLASS_PROP_NAME,
+ "jpos.loader.simple.SimpleServiceManager");
+ JposProperties jposProperties = new DefaultProperties();
+ jposProperties.loadJposProperties();
+ SimpleServiceManager serviceManager = new SimpleServiceManager(jposProperties);
+ serviceManager.getEntryRegistry().load();
+ props = serviceManager.getEntryRegistry();
+ if (props != null && props.getSize() != 0) {
+ initDone = initDevices();
+ } else {
+ LOGGER.debug("no devices are configured in file:{}", configFile);
+ }
}
- /* (non-Javadoc)
- * @see org.eclipse.osbp.ui.api.statemachine.IPeripheral#initDevices()
- */
- @Override
- public void initDevices() {
- if(!devicesInit) {
- // load all names of configured devices, instantiate and cache it
- String configFile = ProductConfiguration.getJavaPosConfiguration();
- try {
- new URL(configFile);
- System.setProperty(
- JposPropertiesConst.JPOS_POPULATOR_FILE_URL_PROP_NAME,
- configFile);
- } catch (MalformedURLException e) {
- System.setProperty(
- JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME,
- configFile);
- }
- System.setProperty(
- JposPropertiesConst.JPOS_REG_POPULATOR_CLASS_PROP_NAME,
- "jpos.config.simple.xml.SimpleXmlRegPopulator");
- System.setProperty(
- JposPropertiesConst.JPOS_SERVICE_MANAGER_CLASS_PROP_NAME,
- "jpos.loader.simple.SimpleServiceManager");
- JposProperties jposProperties = new DefaultProperties();
- jposProperties.loadJposProperties();
- SimpleServiceManager serviceManager = new SimpleServiceManager(
- jposProperties);
- serviceManager.getEntryRegistry().load();
- JposEntryRegistry props = serviceManager.getEntryRegistry();
- Enumeration<?> propsIterator = props.getEntries();
- while (propsIterator.hasMoreElements()) {
- SimpleEntry deviceEntry = (SimpleEntry) propsIterator.nextElement();
- Prop category = deviceEntry.getProp("deviceCategory");
- String deviceClassName = "jpos." + category.getValueAsString();
- try {
- Class<?> deviceClass = Class.forName(deviceClassName);
- Constructor<?> ctor = deviceClass.getConstructor();
- BaseControl device = (BaseControl) ctor.newInstance();
- try {
- // Open the device.
- device.open(deviceEntry.getLogicalName());
- // Get the exclusive control right for the opened device.
- // Then the device is disabled from other application.
- device.claim(1000);
- // Enable the device.
- device.setDeviceEnabled(true);
- // add status listener
- if (device instanceof CashDrawer) {
- ((CashDrawer) device).addStatusUpdateListener(this);
- }
- if (device instanceof POSPrinter) {
- ((POSPrinter) device).addStatusUpdateListener(this);
- ((POSPrinter) device).addErrorListener(this);
- ((POSPrinter) device).addOutputCompleteListener(this);
- // Even if using any printers, 0.01mm unit makes it
- // possible to print neatly.
- ((POSPrinter) device)
- .setMapMode(POSPrinterConst.PTR_MM_METRIC);
- // Output by the high quality mode
- ((POSPrinter) device).setRecLetterQuality(true);
- // 2mm spaces
- ((POSPrinter) device).printNormal(POSPrinterConst.PTR_S_RECEIPT, "\u001b|200uF");
- }
- } catch (JposException ex) {
- LOGGER.error("device init error: {}", ex);
- }
- devices.put(deviceEntry.getLogicalName(), device);
- } catch (Exception e) {
- LOGGER.error("Error creating instance of specified device class:"
- + deviceClassName);
- }
- }
- if(getPTIP() != null) {
- if(POSServiceBinder.getPosService() != null) {
- if(!POSServiceBinder.getPosService().openZVTChannel(getPTIP(), getPTPort())) {
- LOGGER.error("could not open ZVT socket");
- }
- }
- }
- devicesInit = true;
- }
- }
-
/*
* (non-Javadoc)
*
- * @see org.eclipse.osbp.ui.api.abstractstatemachine.IPeripheral#releaseDevices()
+ * @see org.eclipse.osbp.ui.api.statemachine.IPeripheral#isInitDone()
*/
@Override
- public void releaseDevices() {
- if(devicesInit) {
- for (String deviceName : devices.keySet()) {
- try {
- if (devices.get(deviceName) instanceof LineDisplay) {
- try {
- if(windowsCreated > 0) {
- ((LineDisplay) devices.get(deviceName)).destroyWindow();
- }
- } catch (JposException e) {}
- ((LineDisplay) devices.get(deviceName)).clearText();
- }
- devices.get(deviceName).setDeviceEnabled(false);
- if (devices.get(deviceName) instanceof CashDrawer) {
- ((CashDrawer) devices.get(deviceName))
- .removeStatusUpdateListener(this);
- }
- if (devices.get(deviceName) instanceof POSPrinter) {
- ((POSPrinter) devices.get(deviceName))
- .removeStatusUpdateListener(this);
- }
- devices.get(deviceName).release();
- devices.get(deviceName).close();
- } catch (JposException e) {
- LOGGER.error("Error releasing device:" + deviceName);
- }
- }
- if(POSServiceBinder.getPosService() != null) {
- POSServiceBinder.getPosService().closeZVTChannel();
- }
- windowsCreated = 0;
- devicesInit = false;
- }
+ public boolean isInitDone() {
+ return initDone;
}
// line display code
/**
* Sets the display line.
*
+ * @param deviceName
+ * the device name
* @param displayLine
* the new display line
*/
- public void setDisplayLine(String displayLine) {
+ public void setDisplayLine(String deviceName, String displayLine) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
String[] parts = displayLine.split("\\|");
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- if (parts.length > 1) {
- ((LineDisplay) devices.get(device)).displayText(
- parts[0], new Integer(parts[1].trim()));
- } else {
- ((LineDisplay) devices.get(device)).displayText(
- parts[0], LineDisplayConst.DISP_DT_NORMAL);
- }
- } catch (JposException e) {
- LOGGER.error("error displayLine for device:" + device
- + " and text:" + displayLine + " {}", e);
- } catch (Exception ex) {
- LOGGER.error("general error displayLine for device:"
- + device + " text:" + displayLine + " {}", ex);
- }
+ try {
+ if (parts.length > 1) {
+ ((LineDisplay) devices.get(deviceName)).displayText(parts[0], new Integer(parts[1].trim()));
+ } else {
+ ((LineDisplay) devices.get(deviceName)).displayText(parts[0], LineDisplayConst.DISP_DT_NORMAL);
}
+ } catch (JposException e) {
+ LOGGER.error("general error displayLine for device:{} text:{} ex:{}", deviceName, displayLine, e);
+ } catch (Exception ex) {
+ LOGGER.error("general error displayLine for device:{} text:{} ex:{}", deviceName, displayLine, ex);
}
}
/**
* Registers a bitmap.
*
+ * @param deviceName
+ * the device name
* @param registerBitmap
* encodes a pipe separated tuple bitmapNumber, bitmapFilename
*/
- public void setRegisterBitmap(String registerBitmap) {
+ public void setPrinterBitmap(String deviceName, String registerBitmap) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
String[] parts = registerBitmap.split("\\|");
String path = null;
File file = null;
@@ -270,43 +198,64 @@
// get absolute physical path of bundle
file = FileLocator.getBundleFile(FrameworkUtil.getBundle(this.getClass()));
} catch (IOException e) {
- LOGGER.error("jpos error setRegisterBitmap:" + registerBitmap + " {}", e);
+ LOGGER.error("jpos error setRegisterBitmap:{} ex:{}", registerBitmap, e);
return;
}
- if(file != null) {
- path = file.getAbsolutePath()+"/"+parts[1];
+ if (file != null) {
+ path = file.getAbsolutePath() + "/" + parts[1];
}
- if(path != null) {
- for (String device : devices.keySet()) {
- try {
- if (devices.get(device) instanceof LineDisplay) {
- if (((LineDisplayControl114) devices.get(device))
- .getCapBitmap() == true) {
- ((LineDisplayControl114) devices.get(device))
- .setBitmap(new Integer(parts[0]), parts[1],
- LineDisplayConst.DISP_BM_ASIS,
- LineDisplayConst.DISP_BM_LEFT,
- LineDisplayConst.DISP_BM_TOP);
- }
- }
- if (devices.get(device) instanceof POSPrinter) {
- if (((POSPrinterControl114) devices.get(device))
- .getCapRecBitmap() == true) {
- int lineWidth = ((POSPrinterControl114) devices
- .get(device)).getRecLineWidth();
- ((POSPrinterControl114) devices.get(device)).setBitmap(
- new Integer(parts[0]),
- POSPrinterConst.PTR_S_RECEIPT, path,
- lineWidth / 2, POSPrinterConst.PTR_BM_CENTER);
- }
- }
- } catch (JposException e) {
- LOGGER.error("jpos error setRegisterBitmap for device:"
- + device + " and:" + registerBitmap + " {}", e);
- } catch (Exception ex) {
- LOGGER.error("general error registerBitmap for device:"
- + device + " text:" + registerBitmap + " {}", ex);
+ if (path != null) {
+ try {
+ if (((POSPrinterControl114) devices.get(deviceName)).getCapRecBitmap()) {
+ int lineWidth = ((POSPrinterControl114) devices.get(deviceName)).getRecLineWidth();
+ ((POSPrinterControl114) devices.get(deviceName)).setBitmap(new Integer(parts[0]),
+ POSPrinterConst.PTR_S_RECEIPT, path, lineWidth / 2, POSPrinterConst.PTR_BM_CENTER);
}
+ } catch (JposException e) {
+ LOGGER.error("jpos error setRegisterBitmap for device:{} and:{} ex:{}", deviceName, registerBitmap, e);
+ } catch (Exception ex) {
+ LOGGER.error("general error registerBitmap for device:{} text:{} ex:{}", deviceName, registerBitmap,
+ ex);
+ }
+ }
+ }
+
+ /**
+ * Registers a bitmap.
+ *
+ * @param deviceName
+ * the device name
+ * @param registerBitmap
+ * encodes a pipe separated tuple bitmapNumber, bitmapFilename
+ */
+ public void setDisplayBitmap(String deviceName, String registerBitmap) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ String[] parts = registerBitmap.split("\\|");
+ String path = null;
+ File file = null;
+ try {
+ // get absolute physical path of bundle
+ file = FileLocator.getBundleFile(FrameworkUtil.getBundle(this.getClass()));
+ } catch (IOException e) {
+ LOGGER.error("jpos error setRegisterBitmap for device:{} and:{} ex:{}", deviceName, registerBitmap, e);
+ return;
+ }
+ if (file != null) {
+ path = file.getAbsolutePath() + "/" + parts[1];
+ }
+ if (path != null) {
+ try {
+ if (((LineDisplayControl114) devices.get(deviceName)).getCapBitmap()) {
+ ((LineDisplayControl114) devices.get(deviceName)).setBitmap(new Integer(parts[0]), parts[1],
+ LineDisplayConst.DISP_BM_ASIS, LineDisplayConst.DISP_BM_LEFT, LineDisplayConst.DISP_BM_TOP);
+ }
+ } catch (JposException e) {
+ LOGGER.error("jpos error setDisplayBitmap for device:{} and:{} ex:{}", deviceName, registerBitmap, e);
+ } catch (Exception ex) {
+ LOGGER.error("jpos error setDisplayBitmap for device:{} and:{} genericex:{}", deviceName,
+ registerBitmap, ex);
}
}
}
@@ -314,170 +263,159 @@
/**
* Sets the display bitmap.
*
+ * @param deviceName
+ * the device name
* @param displayBitmap
* the new display bitmap
*/
- public void setDisplayBitmap(Integer displayBitmap) {
- String text = String.format("\\u%03db|%dB", displayBitmap,
- displayBitmap);
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- int[] pram2 = new int[1];
- Object pram3 = new Object();
+ public void setDisplayBitmap(String deviceName, Integer displayBitmap) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ String text = String.format("\\u%03db|%dB", displayBitmap, displayBitmap);
+ try {
+ int[] pram2 = new int[1];
+ Object pram3 = new Object();
- ((LineDisplayControl114) devices.get(device))
- .directIO(EpsonLineDisplayConst.DISP_DI_GRAPHIC,
- pram2, pram3);
- ((LineDisplayControl114) devices.get(device)).createWindow(
- 0, 0, 64, 256, 64, 256);
- ((LineDisplayControl114) devices.get(device)).displayText(
- text, LineDisplayConst.DISP_DT_NORMAL);
- } catch (JposException e) {
- LOGGER.error("jpos error setDisplayBitmap for device:"
- + device + " and:" + displayBitmap + " {}", e);
- }
- }
+ ((LineDisplayControl114) devices.get(deviceName)).directIO(EpsonLineDisplayConst.DISP_DI_GRAPHIC, pram2,
+ pram3);
+ ((LineDisplayControl114) devices.get(deviceName)).createWindow(0, 0, 64, 256, 64, 256);
+ ((LineDisplayControl114) devices.get(deviceName)).displayText(text, LineDisplayConst.DISP_DT_NORMAL);
+ } catch (JposException e) {
+ LOGGER.error("jpos error setDisplayBitmap for device:{} and:{} ex:{}", deviceName, displayBitmap, e);
}
}
/**
* Sets the device brightness.
*
+ * @param deviceName
+ * the device name
* @param deviceBrightness
* the new device brightness
*/
- public void setDeviceBrightness(Integer deviceBrightness) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setDeviceBrightness(deviceBrightness);
- } catch (JposException e) {
- LOGGER.error("jpos error deviceBrightness for device:"
- + device + " and:" + deviceBrightness + " {}", e);
- }
- }
+ public void setDeviceBrightness(String deviceName, Integer deviceBrightness) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setDeviceBrightness(deviceBrightness);
+ } catch (JposException e) {
+ LOGGER.error("jpos error deviceBrightness for device:{} and:{} ex:{}", deviceName, deviceBrightness, e);
}
}
/**
* Sets the blink rate.
*
+ * @param deviceName
+ * the device name
* @param blinkRate
* the new blink rate
*/
- public void setBlinkRate(Integer blinkRate) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setBlinkRate(blinkRate);
- } catch (JposException e) {
- LOGGER.error("jpos error blinkRate for device:" + device
- + " and:" + blinkRate + " {}", e);
- }
- }
+ public void setBlinkRate(String deviceName, Integer blinkRate) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setBlinkRate(blinkRate);
+ } catch (JposException e) {
+ LOGGER.error("jpos error blinkRate for device:{} and:{} ex:{}", deviceName, blinkRate, e);
}
}
/**
* Sets the cursor type.
*
+ * @param deviceName
+ * the device name
* @param cursorType
* see: LineDisplayConst
*/
- public void setCursorType(Integer cursorType) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setCursorType(cursorType);
- } catch (JposException e) {
- LOGGER.error("jpos error cursorType for device:" + device
- + " and:" + cursorType + " {}", e);
- }
- }
+ public void setCursorType(String deviceName, Integer cursorType) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setCursorType(cursorType);
+ } catch (JposException e) {
+ LOGGER.error("jpos error cursorType for device:{} and:{} ex:{}", deviceName, cursorType, e);
}
}
/**
* Sets the marquee format.
*
+ * @param deviceName
+ * the device name
* @param marqueeFormat
* the new marquee format
*/
- public void setMarqueeFormat(Integer marqueeFormat) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setMarqueeFormat(marqueeFormat);
- } catch (JposException e) {
- LOGGER.error("jpos error marqueeFormat for device:"
- + device + " and:" + marqueeFormat + " {}", e);
- }
- }
+ public void setMarqueeFormat(String deviceName, Integer marqueeFormat) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setMarqueeFormat(marqueeFormat);
+ } catch (JposException e) {
+ LOGGER.error("jpos error marqueeFormat for device:{} and:{} ex:{}", deviceName, marqueeFormat, e);
}
}
/**
* Sets the marquee repeat wait.
*
+ * @param deviceName
+ * the device name
* @param marqueeRepeatWait
* the new marquee repeat wait
*/
- public void setMarqueeRepeatWait(Integer marqueeRepeatWait) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setMarqueeRepeatWait(marqueeRepeatWait);
- } catch (JposException e) {
- LOGGER.error("jpos error marqueeRepeatWait for device:"
- + device + " and:" + marqueeRepeatWait + " {}", e);
- }
- }
+ public void setMarqueeRepeatWait(String deviceName, Integer marqueeRepeatWait) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setMarqueeRepeatWait(marqueeRepeatWait);
+ } catch (JposException e) {
+ LOGGER.error("jpos error marqueeRepeatWait for device:{} and:{} ex:{}", deviceName, marqueeRepeatWait, e);
}
}
/**
* Sets the marquee type.
*
+ * @param deviceName
+ * the device name
* @param marqueeType
* the new marquee type
*/
- public void setMarqueeType(Integer marqueeType) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setMarqueeType(marqueeType);
- } catch (JposException e) {
- LOGGER.error("jpos error marqueeType for device:" + device
- + " and:" + marqueeType + " {}", e);
- }
- }
+ public void setMarqueeType(String deviceName, Integer marqueeType) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setMarqueeType(marqueeType);
+ } catch (JposException e) {
+ LOGGER.error("jpos error marqueeType for device:{} and:{} ex:{}", deviceName, marqueeType, e);
}
}
/**
* Sets the marquee unit wait.
*
+ * @param deviceName
+ * the device name
* @param marqueeUnitWait
* the new marquee unit wait
*/
- public void setMarqueeUnitWait(Integer marqueeUnitWait) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setMarqueeUnitWait(marqueeUnitWait);
- } catch (JposException e) {
- LOGGER.error("jpos error marqueeUnitWait for device:"
- + device + " and:" + marqueeUnitWait + " {}", e);
- }
- }
+ public void setMarqueeUnitWait(String deviceName, Integer marqueeUnitWait) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setMarqueeUnitWait(marqueeUnitWait);
+ } catch (JposException e) {
+ LOGGER.error("jpos error marqueeUnitWait for device:{} and:{} ex:{}", deviceName, marqueeUnitWait, e);
}
}
@@ -485,385 +423,390 @@
* wraps: createWindow(int viewportRow, int viewportColumn, int
* viewportHeight , int viewportWidth, int windowHeight, int windowWidth);.
*
+ * @param deviceName
+ * the device name
* @param createWindow
* the new creates the window
*/
- public void setCreateWindow(String createWindow) {
+ public void setCreateWindow(String deviceName, String createWindow) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
String[] parts = createWindow.split("\\|");
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device)).createWindow(
- new Integer(parts[0].trim()),
- new Integer(parts[1].trim()),
- new Integer(parts[2].trim()),
- new Integer(parts[3].trim()),
- new Integer(parts[4].trim()),
- new Integer(parts[5].trim()));
- windowsCreated ++;
- } catch (JposException e) {
- LOGGER.error("jpos error createWindow for device:" + device
- + " and:" + createWindow + " {}", e);
- } catch (Exception ex) {
- LOGGER.error("general error createWindow for device:"
- + device + " text:" + createWindow + " {}", ex);
- }
- }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).createWindow(new Integer(parts[0].trim()),
+ new Integer(parts[1].trim()), new Integer(parts[2].trim()), new Integer(parts[3].trim()),
+ new Integer(parts[4].trim()), new Integer(parts[5].trim()));
+ windowsCreated++;
+ } catch (JposException e) {
+ LOGGER.error("jpos error createWindow for device:{} and:{} ex:{}", deviceName, createWindow, e);
+ } catch (Exception ex) {
+ LOGGER.error("jpos error createWindow for device:{} and:{} genericex:{}", deviceName, createWindow, ex);
}
}
/**
* Sets the destroy window.
*
+ * @param deviceName
+ * the device name
* @param destroyWindow
* the new destroy window
*/
- public void setDestroyWindow(String destroyWindow) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- if(windowsCreated > 0) {
- ((LineDisplayControl114) devices.get(device)).destroyWindow();
- windowsCreated --;
- }
- } catch (JposException e) {
- LOGGER.error("jpos error destroyWindow for device:"
- + device + " {}", e);
- }
+ public void setDestroyWindow(String deviceName, String destroyWindow) { // NOSONAR
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ if (windowsCreated > 0) {
+ ((LineDisplayControl114) devices.get(deviceName)).destroyWindow();
+ windowsCreated--;
}
+ } catch (JposException e) {
+ LOGGER.error("jpos error destroyWindow for device:" + deviceName + " {}", e);
}
}
/**
* Sets the scroll.
*
+ * @param deviceName
+ * the device name
* @param scroll
* encodes a pipe separated tuple: direction, units
*/
- public void setScroll(String scroll) {
+ public void setScroll(String deviceName, String scroll) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
String[] parts = scroll.split("\\|");
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device)).scrollText(
- new Integer(parts[0].trim()),
- new Integer(parts[1].trim()));
- } catch (JposException e) {
- LOGGER.error("jpos error scroll for device:" + device
- + " and:" + scroll + " {}", e);
- } catch (Exception ex) {
- LOGGER.error("general error scroll for device:" + device
- + " text:" + scroll + " {}", ex);
- }
- }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).scrollText(new Integer(parts[0].trim()),
+ new Integer(parts[1].trim()));
+ } catch (JposException e) {
+ LOGGER.error("jpos error scroll for device:{} and:{} ex:{}", deviceName, scroll, e);
+ } catch (Exception ex) {
+ LOGGER.error("jpos error scroll for device:{} and:{} genericex:{}", deviceName, scroll, ex);
}
}
/**
* Sets the inter character wait.
*
+ * @param deviceName
+ * the device name
* @param interCharacterWait
* the new inter character wait
*/
- public void setInterCharacterWait(Integer interCharacterWait) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- ((LineDisplayControl114) devices.get(device))
- .setInterCharacterWait(interCharacterWait);
- } catch (JposException e) {
- LOGGER.error("jpos error interCharacterWait for device:"
- + device + " and:" + interCharacterWait + " {}", e);
- }
- }
+ public void setInterCharacterWait(String deviceName, Integer interCharacterWait) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((LineDisplayControl114) devices.get(deviceName)).setInterCharacterWait(interCharacterWait);
+ } catch (JposException e) {
+ LOGGER.error("jpos error interCharacterWait for device:{} and:{} ex:{}", deviceName, interCharacterWait, e);
}
}
/**
* Sets the display at.
*
+ * @param deviceName
+ * the device name
* @param displayTextAt
* encodes a pipe separated quadruple: row, column, text,
* attribute
*/
- public void setDisplayTextAt(String displayTextAt) {
+ public void setDisplayTextAt(String deviceName, String displayTextAt) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
String[] parts = displayTextAt.split("\\|");
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- if (parts.length > 3) {
- ((LineDisplayControl114) devices.get(device))
- .displayTextAt(new Integer(parts[0].trim()),
- new Integer(parts[1].trim()), parts[2],
- new Integer(parts[3].trim()));
- } else {
- ((LineDisplayControl114) devices.get(device))
- .displayTextAt(new Integer(parts[0].trim()),
- new Integer(parts[1].trim()), parts[2],
- LineDisplayConst.DISP_DT_NORMAL);
- }
- } catch (JposException e) {
- LOGGER.error("jpos error displayTextAt for device:"
- + device + " and:" + displayTextAt + " {}", e);
- } catch (Exception ex) {
- LOGGER.error("general error displayTextAt for device:"
- + device + " text:" + displayTextAt + " {}", ex);
- }
+ try {
+ if (parts.length > 3) {
+ ((LineDisplayControl114) devices.get(deviceName)).displayTextAt(new Integer(parts[0].trim()),
+ new Integer(parts[1].trim()), parts[2], new Integer(parts[3].trim()));
+ } else {
+ ((LineDisplayControl114) devices.get(deviceName)).displayTextAt(new Integer(parts[0].trim()),
+ new Integer(parts[1].trim()), parts[2], LineDisplayConst.DISP_DT_NORMAL);
}
+ } catch (JposException e) {
+ LOGGER.error("jpos error displayTextAt for device:{} and:{} ex:{}", deviceName, displayTextAt, e);
+ } catch (Exception ex) {
+ LOGGER.error("jpos error displayTextAt for device:{} and:{} genericex:{}", deviceName, displayTextAt, ex);
}
}
/**
* clears the display.
*
- * @param clearDisplay is nt used
+ * @param deviceName
+ * the device name
+ * @param clearDisplay
+ * is nt used
*/
- public void setClearDisplay(String clearDisplay) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof LineDisplay) {
- try {
- if(windowsCreated > 0) {
- ((LineDisplayControl114) devices.get(device)).destroyWindow();
- windowsCreated --;
- }
- ((LineDisplayControl114) devices.get(device)).clearText();
- } catch (JposException e) {
- LOGGER.error("jpos error clearDisplay for device:" + device
- + " {}", e);
- }
+ public void setClearDisplay(String deviceName, String clearDisplay) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ if (windowsCreated > 0) {
+ ((LineDisplayControl114) devices.get(deviceName)).destroyWindow();
+ windowsCreated--;
}
+ ((LineDisplayControl114) devices.get(deviceName)).clearText();
+ } catch (JposException e) {
+ LOGGER.error("jpos error clearDisplay for device:{} and:{} ex:{}", deviceName, clearDisplay, e);
}
}
/**
* opens the drawer.
*
- * @param openDrawer is ignored
+ * @param deviceName
+ * the device name
+ * @param openDrawer
+ * is ignored
*/
- public void setOpenDrawer(Integer openDrawer) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof CashDrawer) {
- try {
- ((CashDrawerControl114) devices.get(device)).openDrawer();
- } catch (JposException e) {
- LOGGER.error("jpos error openDrawer for device:" + device
- + " {}", e);
- }
- }
+ public void setOpenDrawer(String deviceName, Integer openDrawer) { // NOSONAR
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((CashDrawerControl114) devices.get(deviceName)).openDrawer();
+ } catch (JposException e) {
+ LOGGER.error("jpos error openDrawer for device:" + deviceName + " {}", e);
}
}
/**
* prints to receipt printer in normal mode.
*
- * @param printNormal text to print
+ * @param deviceName
+ * the device name
+ * @param printNormal
+ * text to print
*/
- public void setPrintNormal(String printNormal) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof POSPrinter) {
- try {
- ((POSPrinterControl114) devices.get(device)).printNormal(
- POSPrinterConst.PTR_S_RECEIPT, printNormal);
- } catch (JposException e) {
- LOGGER.error("jpos error printNormal for device:" + device
- + " {}", e);
- }
- }
+ public void setPrintNormal(String deviceName, String printNormal) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ try {
+ ((POSPrinterControl114) devices.get(deviceName)).printNormal(POSPrinterConst.PTR_S_RECEIPT, printNormal);
+ } catch (JposException e) {
+ LOGGER.error("jpos error printNormal for device:" + deviceName + " {}", e);
}
}
/**
* prints footer, feeds paper and cuts.
*
- * @param footer the text to print as footer
+ * @param deviceName
+ * the device name
+ * @param footer
+ * the text to print as footer
*/
- public void setPrintCut(String footer) {
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof POSPrinter) {
- try {
- if (!footer.isEmpty()) {
- ((POSPrinterControl114) devices.get(device))
- .printNormal(POSPrinterConst.PTR_S_RECEIPT,
- footer);
- }
- // Feed the receipt to the cutter position automatically,
- // and cut.
- ((POSPrinterControl114) devices.get(device)).printNormal(
- POSPrinterConst.PTR_S_RECEIPT,
- "\u001b|"
- + (((POSPrinterControl114) devices
- .get(device))
- .getRecLinesToPaperCut()) + "lF");
- if (((POSPrinterControl114) devices.get(device))
- .getCapRecPapercut() == true)
- ((POSPrinterControl114) devices.get(device))
- .cutPaper(100);
- } catch (JposException e) {
- LOGGER.error("jpos error printCut for device:" + device
- + " {}", e);
- }
- }
+ public void setPrintCut(String deviceName, String footer) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
}
-
+ try {
+ if (!footer.isEmpty()) {
+ ((POSPrinterControl114) devices.get(deviceName)).printNormal(POSPrinterConst.PTR_S_RECEIPT, footer);
+ }
+ // Feed the receipt to the cutter position automatically,
+ // and cut.
+ ((POSPrinterControl114) devices.get(deviceName)).printNormal(POSPrinterConst.PTR_S_RECEIPT,
+ "\u001b|" + (((POSPrinterControl114) devices.get(deviceName)).getRecLinesToPaperCut()) + "lF");
+ if (((POSPrinterControl114) devices.get(deviceName)).getCapRecPapercut())
+ ((POSPrinterControl114) devices.get(deviceName)).cutPaper(100);
+ } catch (JposException e) {
+ LOGGER.error("jpos error printCut for device:" + deviceName + " {}", e);
+ }
}
/**
* print a pre-loaded bitmap.
*
- * @param printBitmap the bitmap-id to print
+ * @param deviceName
+ * the device name
+ * @param printBitmap
+ * the bitmap-id to print
*/
- public void setPrintBitmap(Integer printBitmap) {
+ public void setPrintBitmap(String deviceName, Integer printBitmap) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
String text = String.format("\u001b|%dB", printBitmap);
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof POSPrinter) {
- try {
- if (((POSPrinterControl114) devices.get(device)).getCapRecBitmap() == true) {
- int []pram2 = new int[1];
- pram2[0] = EpsonPOSPrinterConst.PTR_DI_BITMAP_PRINTING_MULTI_TONE;
- ((POSPrinterControl114) devices.get(device)).directIO(EpsonPOSPrinterConst.PTR_DI_SET_BITMAP_PRINTING_TYPE, pram2, "");
- ((POSPrinterControl114) devices.get(device)).printNormal(
- POSPrinterConst.PTR_S_RECEIPT, text);
- pram2[0] = EpsonPOSPrinterConst.PTR_DI_BITMAP_PRINTING_NORMAL;
- ((POSPrinterControl114) devices.get(device)).directIO(EpsonPOSPrinterConst.PTR_DI_SET_BITMAP_PRINTING_TYPE, pram2, "");
- }
- } catch (JposException e) {
- LOGGER.error("jpos error setPrintBitmap for device:"
- + device + " and:" + printBitmap + " {}", e);
- }
+ try {
+ if (((POSPrinterControl114) devices.get(deviceName)).getCapRecBitmap()) {
+ int[] pram2 = new int[1];
+ pram2[0] = EpsonPOSPrinterConst.PTR_DI_BITMAP_PRINTING_MULTI_TONE;
+ ((POSPrinterControl114) devices.get(deviceName))
+ .directIO(EpsonPOSPrinterConst.PTR_DI_SET_BITMAP_PRINTING_TYPE, pram2, "");
+ ((POSPrinterControl114) devices.get(deviceName)).printNormal(POSPrinterConst.PTR_S_RECEIPT, text);
+ pram2[0] = EpsonPOSPrinterConst.PTR_DI_BITMAP_PRINTING_NORMAL;
+ ((POSPrinterControl114) devices.get(deviceName))
+ .directIO(EpsonPOSPrinterConst.PTR_DI_SET_BITMAP_PRINTING_TYPE, pram2, "");
}
+ } catch (JposException e) {
+ LOGGER.error("jpos error setPrintBitmap for device:" + deviceName + " and:" + printBitmap + " {}", e);
}
}
-
+
+ /**
+ * show a pre-loaded bitmap.
+ *
+ * @param deviceName
+ * the device name
+ * @param displayBitmap
+ * the display bitmap
+ */
+ public void setShowBitmap(String deviceName, Integer displayBitmap) { // NOSONAR
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
+ }
+
/**
* prints a barcode.
- *
- * @param data the barcode with pipe encoded barcode-type from jpos.POSPrinterConst
+ *
+ * @param deviceName
+ * the device name
+ * @param data
+ * the barcode with pipe encoded barcode-type from
+ * jpos.POSPrinterConst
*/
- public void setPrintBarcode(String data) {
+ public void setPrintBarcode(String deviceName, String data) {
+ if (!initDone || !devices.containsKey(deviceName)) {
+ return;
+ }
String[] parts = data.split("\\|");
- for (String device : devices.keySet()) {
- if (devices.get(device) instanceof POSPrinter) {
- try {
- if (((POSPrinterControl114) devices.get(device)).getCapRecBarCode() == true) {
- // 5mm spaces
- ((POSPrinterControl114) devices.get(device)).printNormal(POSPrinterConst.PTR_S_RECEIPT, "\u001b|500uF");
- ((POSPrinterControl114) devices.get(device)).printBarCode(POSPrinterConst.PTR_S_RECEIPT, parts[0], new Integer(parts[1].trim()),
- 1000, ((POSPrinterControl114) devices.get(device)).getRecLineWidth(), POSPrinterConst.PTR_BC_CENTER,
- POSPrinterConst.PTR_BC_TEXT_BELOW);
- // 2mm spaces
- ((POSPrinterControl114) devices.get(device)).printNormal(POSPrinterConst.PTR_S_RECEIPT, "\u001b|200uF");
- }
- } catch (JposException e) {
- LOGGER.error("jpos error setPrintBitmap for device:"
- + device + " and:" + data + " {}", e);
- }
+ try {
+ if (((POSPrinterControl114) devices.get(deviceName)).getCapRecBarCode()) {
+ // 5mm spaces
+ ((POSPrinterControl114) devices.get(deviceName)).printNormal(POSPrinterConst.PTR_S_RECEIPT,
+ "\u001b|500uF");
+ ((POSPrinterControl114) devices.get(deviceName)).printBarCode(POSPrinterConst.PTR_S_RECEIPT, parts[0],
+ new Integer(parts[1].trim()), 1000,
+ ((POSPrinterControl114) devices.get(deviceName)).getRecLineWidth(),
+ POSPrinterConst.PTR_BC_CENTER, POSPrinterConst.PTR_BC_TEXT_BELOW);
+ // 2mm spaces
+ ((POSPrinterControl114) devices.get(deviceName)).printNormal(POSPrinterConst.PTR_S_RECEIPT,
+ "\u001b|200uF");
}
+ } catch (JposException e) {
+ LOGGER.error("jpos error setPrintBitmap for device:" + deviceName + " and:" + data + " {}", e);
}
}
-
+
+ /**
+ * Sets the slip notifications enabled.
+ *
+ * @param slipNotificationsEnabled
+ * the new slip notifications enabled
+ */
public void setSlipNotificationsEnabled(boolean slipNotificationsEnabled) {
this.slipNotificationsEnabled = slipNotificationsEnabled;
}
+ /**
+ * Checks if is slip notifications enabled.
+ *
+ * @return true, if is slip notifications enabled
+ */
public boolean isSlipNotificationsEnabled() {
return slipNotificationsEnabled;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see jpos.events.StatusUpdateListener#statusUpdateOccurred(jpos.events.
+ * StatusUpdateEvent)
+ */
@Override
- public void statusUpdateOccurred(StatusUpdateEvent e) {
+ public void statusUpdateOccurred(StatusUpdateEvent e) { // NOSONAR
Object source = e.getSource();
if (source instanceof CashDrawer) {
switch (e.getStatus()) {
case CashDrawerConst.CASH_SUE_DRAWERCLOSED: // Drawer is closed.
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGECLOSE, "drawerOpen"));
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.TRIGGER, "onDrawerClosed"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGECLOSE, "drawerOpen"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.TRIGGER, "onDrawerClosed"));
}
break;
case CashDrawerConst.CASH_SUE_DRAWEROPEN: // Drawer is opened.
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGEOPEN, "drawerOpen"));
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.TRIGGER, "onDrawerOpened"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGEOPEN, "drawerOpen"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.TRIGGER, "onDrawerOpened"));
}
break;
+ default:
+ break;
}
}
if (source instanceof POSPrinter) {
switch (e.getStatus()) {
case POSPrinterConst.PTR_SUE_COVER_OPEN:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGEOPEN, "coverOpen"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGEOPEN, "coverOpen"));
}
break;
case POSPrinterConst.PTR_SUE_COVER_OK:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGECLOSE, "coverOpen"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGECLOSE, "coverOpen"));
}
break;
case POSPrinterConst.PTR_SUE_REC_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGEOPEN, "receiptEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGEOPEN, "receiptEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_REC_PAPEROK:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGECLOSE, "receiptEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGECLOSE, "receiptEmpty"));
statemachine.processEvent(statemachine,
new MessageEvent(EventType.STATUSCLOSE, "receiptNearEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_REC_NEAREMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.STATUSOPEN, "receiptNearEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.STATUSOPEN, "receiptNearEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_SLP_EMPTY:
if (statemachine != null && slipNotificationsEnabled) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGEOPEN, "slipEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGEOPEN, "slipEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_SLP_PAPEROK:
if (statemachine != null && slipNotificationsEnabled) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGECLOSE, "slipEmpty"));
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.STATUSCLOSE, "slipNearEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGECLOSE, "slipEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.STATUSCLOSE, "slipNearEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_SLP_NEAREMPTY:
if (statemachine != null && slipNotificationsEnabled) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.STATUSOPEN, "slipNearEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.STATUSOPEN, "slipNearEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_JRN_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGEOPEN, "journalEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGEOPEN, "journalEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_JRN_PAPEROK:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.MESSAGECLOSE, "journalEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.MESSAGECLOSE, "journalEmpty"));
statemachine.processEvent(statemachine,
new MessageEvent(EventType.STATUSCLOSE, "journalNearEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_JRN_NEAREMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.STATUSOPEN, "journalNearEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.STATUSOPEN, "journalNearEmpty"));
}
break;
case POSPrinterConst.PTR_SUE_REC_CARTRIDGE_EMPTY:
@@ -908,8 +851,7 @@
break;
case POSPrinterConst.PTR_SUE_SLP_HEAD_CLEANING:
if (statemachine != null) {
- statemachine.processEvent(statemachine,
- new MessageEvent(EventType.STATUSOPEN, "slipHeadCleaning"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.STATUSOPEN, "slipHeadCleaning"));
}
break;
case POSPrinterConst.PTR_SUE_SLP_CARTDRIGE_OK:
@@ -950,95 +892,93 @@
new MessageEvent(EventType.STATUSCLOSE, "journalCartridgeNearEmpty"));
}
break;
+ default:
+ break;
}
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see jpos.events.ErrorListener#errorOccurred(jpos.events.ErrorEvent)
+ */
@Override
- public void errorOccurred(ErrorEvent e) {
+ public void errorOccurred(ErrorEvent e) { // NOSONAR
switch (e.getErrorCodeExtended()) {
case POSPrinterConst.JPOS_EPTR_COVER_OPEN:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorCoverOpen"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorCoverOpen"));
}
break;
case POSPrinterConst.JPOS_EPTR_JRN_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorJournalEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorJournalEmpty"));
}
break;
case POSPrinterConst.JPOS_EPTR_REC_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorReceiptEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorReceiptEmpty"));
}
break;
case POSPrinterConst.JPOS_EPTR_SLP_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorSlipEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorSlipEmpty"));
}
break;
case POSPrinterConst.JPOS_EPTR_BADFORMAT:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorBadFormat"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorBadFormat"));
}
break;
case POSPrinterConst.JPOS_EPTR_JRN_CARTRIDGE_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorJournalCartdridgeEmpty"));
+ statemachine.processEvent(statemachine,
+ new MessageEvent(EventType.ERROR, "errorJournalCartdridgeEmpty"));
}
break;
case POSPrinterConst.JPOS_EPTR_REC_CARTRIDGE_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorReceiptCartdridgeEmpty"));
+ statemachine.processEvent(statemachine,
+ new MessageEvent(EventType.ERROR, "errorReceiptCartdridgeEmpty"));
}
break;
case POSPrinterConst.JPOS_EPTR_SLP_CARTRIDGE_EMPTY:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorSlipCartdridgeEmpty"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorSlipCartdridgeEmpty"));
}
break;
case POSPrinterConst.JPOS_EPTR_JRN_CARTRIDGE_REMOVED:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorJournalCartdridgeRemoved"));
+ statemachine.processEvent(statemachine,
+ new MessageEvent(EventType.ERROR, "errorJournalCartdridgeRemoved"));
}
break;
case POSPrinterConst.JPOS_EPTR_REC_CARTRIDGE_REMOVED:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorReceiptCartdridgeRemoved"));
+ statemachine.processEvent(statemachine,
+ new MessageEvent(EventType.ERROR, "errorReceiptCartdridgeRemoved"));
}
break;
case POSPrinterConst.JPOS_EPTR_SLP_CARTRIDGE_REMOVED:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorSlipCartdridgeRemoved"));
+ statemachine.processEvent(statemachine,
+ new MessageEvent(EventType.ERROR, "errorSlipCartdridgeRemoved"));
}
break;
case POSPrinterConst.JPOS_EPTR_JRN_HEAD_CLEANING:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorJournalHeadCleaning"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorJournalHeadCleaning"));
}
break;
case POSPrinterConst.JPOS_EPTR_REC_HEAD_CLEANING:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorReceiptHeadCleaning"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorReceiptHeadCleaning"));
}
break;
case POSPrinterConst.JPOS_EPTR_SLP_HEAD_CLEANING:
if (statemachine != null) {
- statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR,
- "errorSlipHeadCleaning"));
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.ERROR, "errorSlipHeadCleaning"));
}
break;
default:
@@ -1046,124 +986,301 @@
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jpos.events.OutputCompleteListener#outputCompleteOccurred(jpos.events.
+ * OutputCompleteEvent)
+ */
@Override
public void outputCompleteOccurred(OutputCompleteEvent e) {
- // TODO Auto-generated method stub
-
+ // nothing to do
}
-
+
+ /**
+ * Gets the ptip.
+ *
+ * @return the ptip
+ */
public String getPTIP() {
return ptIP;
}
+ /**
+ * Sets the ptip.
+ *
+ * @param ptIP
+ * the new ptip
+ */
public void setPTIP(String ptIP) {
this.ptIP = ptIP;
}
+ /**
+ * Gets the PT port.
+ *
+ * @return the PT port
+ */
public Integer getPTPort() {
return ptPort;
}
+ /**
+ * Sets the PT port.
+ *
+ * @param ptPort
+ * the new PT port
+ */
public void setPTPort(Integer ptPort) {
this.ptPort = ptPort;
}
+ /**
+ * Sets the payment terminal open.
+ *
+ * @param connectionParameters
+ * the new payment terminal open
+ */
public void setPaymentTerminalOpen(String connectionParameters) {
String[] parts = connectionParameters.split("\\|");
setPTIP(parts[0]);
setPTPort(Integer.parseInt(parts[1]));
-
- if(POSServiceBinder.getPosService() != null) {
- if(!POSServiceBinder.getPosService().openZVTChannel(getPTIP(), getPTPort())) {
- LOGGER.error("could not open ZVT socket");
- }
+
+ if (initDone && POSServiceBinder.getPosService() != null
+ && !POSServiceBinder.getPosService().openZVTChannel(getPTIP(), getPTPort())) {
+ LOGGER.error("could not open ZVT socket");
}
}
-
- public void setClosePaymentTerminal(String close) {
- if(POSServiceBinder.getPosService() != null) {
+
+ /**
+ * Sets the close payment terminal.
+ *
+ * @param close
+ * the new close payment terminal
+ */
+ public void setClosePaymentTerminal(String close) { // NOSONAR
+ if (initDone && POSServiceBinder.getPosService() != null) {
POSServiceBinder.getPosService().closeZVTChannel();
}
}
-
- public void setPaymentTerminalAcknowledge(String dummey) {
- if(POSServiceBinder.getPosService() != null) {
+
+ /**
+ * Sets the payment terminal acknowledge.
+ *
+ * @param dummey
+ * the new payment terminal acknowledge
+ */
+ public void setPaymentTerminalAcknowledge(String dummey) { // NOSONAR
+ if (initDone && POSServiceBinder.getPosService() != null) {
POSServiceBinder.getPosService().zvtAcknowledge();
}
}
- public void setPaymentTerminalBalanceRequest(String request) {
- if(POSServiceBinder.getPosService() != null) {
-// zvt.balanceRequest();
+ /**
+ * Sets the payment terminal balance request.
+ *
+ * @param request
+ * the new payment terminal balance request
+ */
+ public void setPaymentTerminalBalanceRequest(String request) { // NOSONAR
+ if (initDone && POSServiceBinder.getPosService() != null) {
+ // zvt.balanceRequest();
}
}
-
- public void setPaymentTerminalPrepaidTopUp(Double amount) {
- if(POSServiceBinder.getPosService() != null) {
-// zvt.prepaidTopUp(amount);
+
+ /**
+ * Sets the payment terminal prepaid top up.
+ *
+ * @param amount
+ * the new payment terminal prepaid top up
+ */
+ public void setPaymentTerminalPrepaidTopUp(Double amount) { // NOSONAR
+ if (initDone && POSServiceBinder.getPosService() != null) {
+ // zvt.prepaidTopUp(amount);
}
}
-
+
+ /**
+ * Sets the payment terminal reversal.
+ *
+ * @param reversal
+ * the new payment terminal reversal
+ */
public void setPaymentTerminalReversal(String reversal) {
String[] parts = reversal.split("\\|");
- if(POSServiceBinder.getPosService() != null) {
+ if (initDone && POSServiceBinder.getPosService() != null) {
POSServiceBinder.getPosService().zvtReversal(parts[0], parts[1]);
}
}
-
+
+ /**
+ * Sets the payment terminal registration.
+ *
+ * @param registration
+ * the new payment terminal registration
+ */
public void setPaymentTerminalRegistration(String registration) {
String[] parts = registration.split("\\|");
- if(POSServiceBinder.getPosService() != null) {
+ if (initDone && POSServiceBinder.getPosService() != null) {
POSServiceBinder.getPosService().zvtRegistration(parts[0], parts[1]);
}
}
-
+
+ /**
+ * Sets the payment terminal authorization.
+ *
+ * @param amount
+ * the new payment terminal authorization
+ */
public void setPaymentTerminalAuthorization(Double amount) {
- if(POSServiceBinder.getPosService() != null) {
+ if (initDone && POSServiceBinder.getPosService() != null) {
POSServiceBinder.getPosService().zvtAuthorization(amount);
}
}
-
+
+ /**
+ * Gets the payment terminal response.
+ *
+ * @return the payment terminal response
+ */
public String getPaymentTerminalResponse() {
- if(POSServiceBinder.getPosService() != null) {
+ if (initDone && POSServiceBinder.getPosService() != null) {
return POSServiceBinder.getPosService().getZvtResponse();
}
return null;
}
-
+
+ /**
+ * Gets the payment terminal transaction.
+ *
+ * @return the payment terminal transaction
+ */
public IZVTTransactionData getPaymentTerminalTransaction() {
- if(POSServiceBinder.getPosService() != null) {
+ if (initDone && POSServiceBinder.getPosService() != null) {
return POSServiceBinder.getPosService().getZvtTransactionData();
}
return null;
}
-
+
+ /**
+ * Sets the prints the report.
+ *
+ * @param reportParameters
+ * the new prints the report
+ */
public void setPrintReport(String reportParameters) {
- if(statemachine.getReportProvider() != null) {
+ if (statemachine.getReportProvider() != null) {
String[] parts = reportParameters.split("\\|");
String reportName = parts[0];
Map<String, String> filterMap = new HashMap<>();
// the filter is optional
- if(parts.length > 1 ) {
+ if (parts.length > 1) {
String storageKey = parts[1];
String filterName = null;
String filterValue = null;
- for(String attribute : statemachine.getStorageAttributes(parts[1])) {
- if("filterName".equals(attribute)) {
- filterName = (String)statemachine.getStorage(storageKey, attribute);
+ for (String attribute : statemachine.getStorageAttributes(parts[1])) {
+ if ("filterName".equals(attribute)) {
+ filterName = (String) statemachine.getStorage(storageKey, attribute);
}
- if("filterValue".equals(attribute)) {
- filterValue = (String)statemachine.getStorage(storageKey, attribute);
+ if ("filterValue".equals(attribute)) {
+ filterValue = (String) statemachine.getStorage(storageKey, attribute);
}
- if(filterName != null && filterValue != null) {
- // TODO: as soon as report supports cube datamarts, the slicerSingleSelectDecorator must be added
+ if (filterName != null && filterValue != null) {
+ // TODO: as soon as report supports cube datamarts, the
+ // slicerSingleSelectDecorator must be added
filterMap.put(filterName, filterValue);
filterName = null;
filterValue = null;
}
}
}
- statemachine.getReportProvider().printReportAsPdf(reportName, statemachine.getUser(), statemachine.getDslMetadataService(), filterMap);
+ statemachine.getReportProvider().printReportAsPdf(reportName, statemachine.getUser(),
+ statemachine.getDslMetadataService(), statemachine.getBlobService(), filterMap);
}
}
+
+ public void setSignatureOpen(String dummy) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ if(POSServiceBinder.getSignatureService().openTablet(statemachine.getBlobService())) {
+ statemachine.schedule(statemachine, 500L, new MessageEvent(EventType.TRIGGER, "onSignaturePadOpen"));
+ }
+ }
+ }
+
+ public void setSignatureCapture(String dummy) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().captureTablet();
+ POSServiceBinder.getSignatureService().addListener(this);
+ }
+ }
+
+ public void setSignatureIdle(String dummy) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().removeListener(this);
+ POSServiceBinder.getSignatureService().idleTablet();
+ }
+ }
+
+ public void setSignatureCaptureImage(String imageId) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().setCaptureImage(imageId);
+ }
+ }
+
+ public void setSignatureAddSlide(String slideId) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().addSlideTablet(slideId);
+ }
+ }
+
+ public void setSignatureSlideDelay(int delay) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().setSlideDelay(delay);
+ }
+ }
+
+ public void setSignatureClose(String dummy) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().removeListener(this);
+ POSServiceBinder.getSignatureService().closeTablet();
+ }
+ }
+
+ public void setSignatureLabel(String labels) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().setTabletLabel(labels);
+ }
+ }
+
+ @Override
+ public void notifyFinished(ISignatureEvent event) {
+ if(event.getButtonId() == 1) {
+ penData.clear();
+ penData.addAll(event.getPenData());
+ POSServiceBinder.getSignatureService().removeListener(this);
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.TRIGGER, "onSignatureOk"));
+ POSServiceBinder.getSignatureService().idleTablet();
+ }
+ if(event.getButtonId() == 2) {
+ if(POSServiceBinder.getSignatureService() != null) {
+ POSServiceBinder.getSignatureService().clearTablet();
+ }
+ }
+ if(event.getButtonId() == 3) {
+ penData.clear();
+ POSServiceBinder.getSignatureService().removeListener(this);
+ statemachine.processEvent(statemachine, new MessageEvent(EventType.TRIGGER, "onSignatureCancel"));
+ POSServiceBinder.getSignatureService().idleTablet();
+ }
+
+ }
+
+ public List<PenData> getPenData() {
+ return penData;
+ }
+
+ public String getSignatureBlob() {
+ return POSServiceBinder.getSignatureService().getSignatureBlob(statemachine.getSceenWidth(), statemachine.getScreenHeight());
+ }
}
diff --git a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachine.java b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachine.java
index 545afb6..b79a6a9 100644
--- a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachine.java
+++ b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachine.java
@@ -14,21 +14,27 @@
package org.eclipse.osbp.abstractstatemachine;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.nio.channels.SelectableChannel;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import java.util.Stack;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.annotation.PreDestroy;
+import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.osbp.dsl.common.datatypes.IDto;
-import org.eclipse.osbp.dsl.dto.lib.services.Query;
+import org.eclipse.osbp.runtime.common.filter.IQuery;
+import org.eclipse.osbp.runtime.common.session.ISession;
+import org.eclipse.osbp.ui.api.customfields.IBlobService;
import org.eclipse.osbp.ui.api.message.IMessageRequester;
import org.eclipse.osbp.ui.api.message.MessageEvent;
import org.eclipse.osbp.ui.api.message.MessageEvent.EventType;
@@ -45,13 +51,15 @@
import org.eclipse.osbp.utils.vaadin.YesNoDialog;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
+import org.slf4j.Logger;
import com.vaadin.server.Page;
import com.vaadin.server.WebBrowser;
import com.vaadin.ui.UI;
-public abstract class AbstractStateMachine implements IStateMachine,
- IMessageRequester.ClickRecipient {
+public abstract class AbstractStateMachine implements IStateMachine, IMessageRequester.ClickRecipient {
+ private static final String ENABLED = "Enabled";
+ private static Logger logger = org.slf4j.LoggerFactory.getLogger("statemachine");
protected Collection<IEventSource.Enabler> enablerList = new CopyOnWriteArraySet<>();
protected Collection<IDataProvider.Provider> providerList = new CopyOnWriteArraySet<>();
protected Collection<IPeripheral.Command> peripheralList = new CopyOnWriteArraySet<>();
@@ -64,10 +72,11 @@
protected IDSLMetadataService dslMetadataService;
protected IThemeResourceService themeResourceService;
protected IReportProvider reportProvider;
- protected Stack<Object> parameters = new Stack<>();
+ protected IBlobService blobService;
protected Map<String, Map<String, Object>> storage = new HashMap<>();
protected SelectableChannel channel;
protected String lastTrigger;
+ protected IEclipseContext eclipseContext;
private void addEventProvider(IEventSource.Enabler listener) {
enablerList.add(listener);
@@ -96,7 +105,7 @@
public IUser getUser() {
return user;
}
-
+
@Override
public String getUserName() {
return user.getUserName();
@@ -133,11 +142,6 @@
}
@Override
- public Stack<Object> getParameters() {
- return parameters;
- }
-
- @Override
public void setDslMetadataService(IDSLMetadataService dslMetadataService) {
this.dslMetadataService = dslMetadataService;
}
@@ -153,8 +157,7 @@
}
@Override
- public void setThemeResourceService(
- IThemeResourceService themeResourceService) {
+ public void setThemeResourceService(IThemeResourceService themeResourceService) {
this.themeResourceService = themeResourceService;
}
@@ -169,6 +172,16 @@
}
@Override
+ public IBlobService getBlobService() {
+ return blobService;
+ }
+
+ @Override
+ public void setBlobService(IBlobService blobService) {
+ this.blobService = blobService;
+ }
+
+ @Override
public void enable(String id, Boolean enable) {
for (IEventSource.Enabler listener : enablerList) {
listener.enable(listener, id, enable);
@@ -176,8 +189,21 @@
}
@Override
+ public void toggle(String id) {
+ for (IEventSource.Enabler listener : enablerList) {
+ listener.toggle(listener, id + ENABLED);
+ }
+ for (IDataProvider.Provider listener : providerList) {
+ listener.toggle(listener, id + ENABLED);
+ }
+ for (IPeripheral.Command listener : peripheralList) {
+ listener.toggle(listener, id + ENABLED);
+ }
+ }
+
+ @Override
public Object get(String id) {
- Object value = null;
+ Object value;
for (IEventSource.Enabler listener : enablerList) {
value = listener.get(listener, id);
if (value != null) {
@@ -213,6 +239,13 @@
}
@Override
+ public void set(String id, String device, Object content) {
+ for (IPeripheral.Command listener : peripheralList) {
+ listener.set(listener, id, device, content);
+ }
+ }
+
+ @Override
public void clear(String id) {
for (IEventSource.Enabler listener : enablerList) {
listener.clear(listener, id);
@@ -292,7 +325,7 @@
}
@Override
- public Boolean find(String dtoName, Query query) {
+ public Boolean find(String dtoName, IQuery query) {
Boolean retVal;
for (IDataProvider.Provider listener : providerList) {
retVal = listener.find(listener, dtoName, query);
@@ -316,6 +349,30 @@
}
@Override
+ public Collection<? extends IDto> findAll(String dtoName, IQuery query) {
+ Collection<? extends IDto> retVal;
+ for (IDataProvider.Provider listener : providerList) {
+ retVal = listener.findAll(dtoName, query);
+ if (retVal != null) {
+ return retVal;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Collection<? extends IDto> findAll(String dtoName, String fieldName, Object search) {
+ Collection<? extends IDto> retVal;
+ for (IDataProvider.Provider listener : providerList) {
+ retVal = listener.findAll(dtoName, fieldName, search);
+ if (retVal != null) {
+ return retVal;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
public void addTo(String dtoName, String listName, IDto dto) {
for (IDataProvider.Provider listener : providerList) {
listener.addTo(listener, dtoName, listName, dto);
@@ -332,32 +389,25 @@
@Override
public void update(String dtoName) {
for (IDataProvider.Provider listener : providerList) {
- listener.update(listener, dtoName,
- (IDto) listener.get(listener, dtoName));
+ listener.update(listener, dtoName, (IDto) listener.get(listener, dtoName));
+ }
+ }
+
+ @Override
+ public void reload(String dtoName) {
+ for (IDataProvider.Provider listener : providerList) {
+ listener.reload(listener, dtoName, (IDto) listener.get(listener, dtoName));
}
}
@Override
public void delete(String dtoName) {
for (IDataProvider.Provider listener : providerList) {
- listener.delete(listener, dtoName,
- (IDto) listener.get(listener, dtoName));
+ listener.delete(listener, dtoName, (IDto) listener.get(listener, dtoName));
}
}
@Override
- public Boolean operation(String name, Stack<Object> parameter) {
- Boolean retVal;
- for (IDataProvider.Provider listener : providerList) {
- retVal = listener.operation(listener, name, parameter);
- if (retVal != null) {
- return retVal;
- }
- }
- return false;
- }
-
- @Override
public String getIPAddress() {
// must define -Djava.net.preferIPv4Stack=true to always get IPv4 in
// dual stack environments
@@ -366,6 +416,31 @@
}
@Override
+ public String getHostName() {
+ String hostName = null;
+ try {
+ InetAddress netAddress = InetAddress.getByName(webBrowser.getAddress());
+ hostName = netAddress.getHostName();
+ } catch (UnknownHostException e) {
+ logger.error("{}", e);
+ }
+ return hostName;
+ }
+
+ @Override
+ public boolean isItMe(String hostName) {
+ String hostAddress;
+ try {
+ InetAddress netAddress = InetAddress.getByName(hostName);
+ hostAddress = netAddress.getHostAddress();
+ } catch (UnknownHostException e) {
+ logger.error("{}", e);
+ return false;
+ }
+ return getIPAddress().equals(hostAddress);
+ }
+
+ @Override
public DateTime getNow() {
return DateTime.now(DateTimeZone.UTC);
}
@@ -407,8 +482,7 @@
}
@Override
- public void schedule(IStateMachine statemachine, long milliseconds,
- MessageEvent event) {
+ public void schedule(IStateMachine statemachine, long milliseconds, MessageEvent event) {
if (timer == null) {
timer = new Timer();
} else {
@@ -428,6 +502,7 @@
this.event = event;
}
+ @Override
public void run() {
if (UI.getCurrent().isAttached())
statemachine.processEvent(statemachine, event);
@@ -445,8 +520,7 @@
return 0.0;
}
if (doubleStrIn.matches(".+\\.\\d+,\\d+$"))
- return Double.parseDouble(doubleStrIn.replaceAll("\\.", "")
- .replaceAll(",", "."));
+ return Double.parseDouble(doubleStrIn.replaceAll("\\.", "").replaceAll(",", "."));
if (doubleStrIn.matches(".+,\\d+\\.\\d+$"))
return Double.parseDouble(doubleStrIn.replaceAll(",", ""));
return Double.parseDouble(doubleStrIn.replaceAll(",", "."));
@@ -471,7 +545,10 @@
@Override
public String getTranslation(String token) {
- return dslMetadataService.translate(locale.toLanguageTag(), token);
+ if (dslMetadataService != null && locale != null) {
+ return dslMetadataService.translate(locale.toLanguageTag(), token);
+ }
+ return token;
}
@Override
@@ -481,7 +558,6 @@
messageDialog.close();
UI.getCurrent().removeWindow(messageDialog);
messageDialogs.remove(messageId);
- messageDialog = null;
}
}
@@ -492,11 +568,9 @@
@Override
public void openMessage(String messageId, boolean okButton) {
- MessageDialog messageDialog = new MessageDialog(messageId,
- getTranslation(messageId));
+ MessageDialog messageDialog = new MessageDialog(messageId, getTranslation(messageId));
if (okButton) {
- messageDialog.addButton(getTranslation("ok"), new MessageEvent(
- EventType.MESSAGECLOSE, messageId));
+ messageDialog.addButton(getTranslation("ok"), new MessageEvent(EventType.MESSAGECLOSE, messageId));
messageDialog.addButtonListener(this);
}
messageDialogs.put(messageId, messageDialog);
@@ -504,16 +578,11 @@
}
@Override
- public void openQuestion(String messageId, EventType type, String yesEvent,
- String noEvent, String cancelEvent) {
- MessageDialog messageDialog = new MessageDialog(messageId,
- getTranslation(messageId));
- messageDialog.addButton(getTranslation("yes"), new MessageEvent(type,
- yesEvent));
- messageDialog.addButton(getTranslation("no"), new MessageEvent(type,
- noEvent));
- messageDialog.addButton(getTranslation("cancel"), new MessageEvent(
- type, cancelEvent));
+ public void openQuestion(String messageId, EventType type, String yesEvent, String noEvent, String cancelEvent) {
+ MessageDialog messageDialog = new MessageDialog(messageId, getTranslation(messageId));
+ messageDialog.addButton(getTranslation("yes"), new MessageEvent(type, yesEvent));
+ messageDialog.addButton(getTranslation("no"), new MessageEvent(type, noEvent));
+ messageDialog.addButton(getTranslation("cancel"), new MessageEvent(type, cancelEvent));
messageDialog.addButtonListener(this);
messageDialogs.put(messageId, messageDialog);
UI.getCurrent().addWindow(messageDialog);
@@ -525,7 +594,6 @@
messageDialog.close();
UI.getCurrent().removeWindow(messageDialog);
messageDialogs.remove(e.getId());
- messageDialog = null;
this.processEvent(this, e.getEventData());
}
@@ -541,24 +609,17 @@
case MESSAGEOPEN:
openMessage(event.getId());
break;
- case STATUSOPEN:
- break;
case MESSAGECLOSE:
closeMessage(event.getId());
break;
+ case STATUSOPEN:
case STATUSCLOSE:
- break;
default:
break;
}
}
@Override
- public void clearParameters() {
- parameters.clear();
- }
-
- @Override
public Object getStorage(String key, String attribute) {
if (storage.containsKey(key) && storage.get(key).containsKey(attribute)) {
return storage.get(key).get(attribute);
@@ -571,7 +632,7 @@
if (storage.containsKey(key)) {
return storage.get(key).keySet();
}
- return null;
+ return Collections.emptySet();
}
@Override
@@ -597,7 +658,7 @@
if (channel != null) {
try {
channel.close();
- } catch (IOException e) {
+ } catch (IOException e) { // NOSONAR
// do nothing
}
}
@@ -607,4 +668,30 @@
public String getLastTrigger() {
return lastTrigger;
}
+
+ @Override
+ public void setEclipseContext(IEclipseContext eclipseContext) {
+ this.eclipseContext = eclipseContext;
+ }
+
+ @Override
+ public IEclipseContext getEclipseContext() {
+ return eclipseContext;
+ }
+
+ @Override
+ public void sendSlaveData(Map<String, Object> data) {
+ String currentInstanceId = (String) getEclipseContext().get("e4ApplicationInstanceId");
+ List<ISession> sessions = POSServiceBinder.getSessionManager()
+ .getSessions((s) -> s.get("e4ApplicationInstanceId").equals(currentInstanceId));
+ if (!sessions.isEmpty()) {
+ List<ISession> slaves = sessions.get(0).getSlaves();
+ for (ISession slave : slaves) {
+ slave.async(e -> {
+ slave.sendData(data);
+ return true;
+ }, null);
+ }
+ }
+ }
}
diff --git a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachineParticipant.java b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachineParticipant.java
index 8211ff8..a323000 100644
--- a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachineParticipant.java
+++ b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/AbstractStateMachineParticipant.java
@@ -16,17 +16,16 @@
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
+import java.beans.MethodDescriptor;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.math.BigDecimal;
import java.util.Date;
import java.util.Locale;
import org.eclipse.osbp.dsl.common.datatypes.IDto;
-import org.eclipse.osbp.ecview.core.common.context.IViewContext;
import org.eclipse.osbp.ui.api.statemachine.IStateMachine;
import org.eclipse.osbp.ui.api.statemachine.IStateMachineParticipant;
import org.joda.time.DateTime;
@@ -41,7 +40,6 @@
.getLogger(AbstractStateMachineParticipant.class);
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
protected IStateMachine statemachine;
- protected IViewContext viewContext;
protected Locale locale;
public void addPropertyChangeListener(PropertyChangeListener listener) {
@@ -73,11 +71,6 @@
}
@Override
- public void setViewContext(IViewContext viewContext) {
- this.viewContext = viewContext;
- }
-
- @Override
public void setLocale(Locale locale) {
this.locale = locale;
}
@@ -101,19 +94,20 @@
return null;
}
- @Override
- public Method setter(Object listener, String id,
- Class<?> parameter) {
+ @Override
+ public Method setter(Object listener, String id, Class<?> parameter, int contentIndex) {
if (id == null) {
return null;
}
Class<?> clz = listener.getClass();
try {
BeanInfo info = Introspector.getBeanInfo(clz);
- for (PropertyDescriptor desc : info.getPropertyDescriptors()) {
- if (desc.getName().equalsIgnoreCase(id)) {
- if (parameter.isAssignableFrom(desc.getPropertyType())) {
- return desc.getWriteMethod();
+ for (MethodDescriptor desc : info.getMethodDescriptors()) {
+ if (desc.getName().equalsIgnoreCase("set"+id)) {
+ Method method = desc.getMethod();
+ Class<?>[] paras = method.getParameterTypes();
+ if(paras.length > contentIndex) {
+ return desc.getMethod();
}
}
}
@@ -124,6 +118,19 @@
}
@Override
+ public Method setter(Object listener, String id, Class<?> parameter) {
+ return setter(listener, id, parameter, 0);
+ }
+ @Override
+ public Method setter(Object listener, String id, Object content, int contentIndex) {
+ if(content != null) {
+ return setter(listener, id, content.getClass(), contentIndex);
+ } else {
+ return setter(listener, id, null, contentIndex);
+ }
+ }
+
+ @Override
public Class<?> getReturnType(Object obj, String id) {
if (id == null) {
return null;
@@ -145,53 +152,34 @@
}
@Override
+ public void toggle(Object obj, String id) {
+ Object result = get(obj, id);
+ if(result != null) {
+ if(result.getClass().isAssignableFrom(Boolean.class)) {
+ if((Boolean)result) {
+ set(obj, id, false);
+ } else {
+ set(obj, id, true);
+ }
+ }
+ if(result.getClass().isAssignableFrom(boolean.class)) {
+ if((boolean)result) {
+ set(obj, id, false);
+ } else {
+ set(obj, id, true);
+ }
+ }
+ } else {
+ set(obj, id, true);
+ }
+ }
+
+ @Override
public void set(Object obj, String id, Object content) {
try {
- if (content instanceof String) {
- Method method = setter(obj, id, String.class);
- if (method != null) {
- method.invoke(obj, (String) content);
- }
- } else if (content instanceof Double) {
- Method method = setter(obj, id, Double.class);
- if (method != null) {
- method.invoke(obj, (Double) content);
- }
- } else if (content instanceof Integer) {
- Method method = setter(obj, id, Integer.class);
- if (method != null) {
- method.invoke(obj, (Integer) content);
- }
- } else if (content instanceof Long) {
- Method method = setter(obj, id, Long.class);
- if (method != null) {
- method.invoke(obj, (Long) content);
- }
- } else if (content instanceof Boolean) {
- Method method = setter(obj, id, Boolean.class);
- if (method != null) {
- method.invoke(obj, (Boolean) content);
- }
- } else if (content instanceof BigDecimal) {
- Method method = setter(obj, id, BigDecimal.class);
- if (method != null) {
- method.invoke(obj, (BigDecimal) content);
- }
- } else if (content instanceof IDto) {
- Method method = setter(obj, id, IDto.class);
- if (method != null) {
- method.invoke(obj, (IDto) content);
- }
- } else if (content instanceof Date) {
- Method method = setter(obj, id, Date.class);
- if (method != null) {
- method.invoke(obj, (Date) content);
- }
- } else if (content instanceof DateTime) {
- Method method = setter(obj, id, DateTime.class);
- if (method != null) {
- method.invoke(obj, (DateTime) content);
- }
+ Method method = setter(obj, id, content, 0);
+ if (method != null) {
+ method.invoke(obj, content);
}
} catch (IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
@@ -200,6 +188,19 @@
}
@Override
+ public void set(Object obj, String id, String device, Object content) {
+ try {
+ Method method = setter(obj, id, content, 1);
+ if (method != null) {
+ method.invoke(obj, device, content);
+ }
+ } catch (IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException e) {
+ LOGGER.error("{}", e);
+ }
+ }
+
+ @Override
public Object get(Object obj, String id) {
Method method = getter(obj, id);
if (method == null) {
@@ -216,7 +217,7 @@
@Override
public void clear(Object obj, String id) {
- Method method = setter(obj, id, String.class);
+ Method method = setter(obj, id, "", 0);
if (method != null) {
try {
method.invoke(obj, "");
@@ -226,7 +227,7 @@
LOGGER.error("{}", e);
}
}
- method = setter(obj, id, Double.class);
+ method = setter(obj, id, 0.0, 0);
if (method != null) {
try {
method.invoke(obj, 0.0);
@@ -236,17 +237,7 @@
LOGGER.error("{}", e);
}
}
- method = setter(obj, id, BigDecimal.class);
- if (method != null) {
- try {
- method.invoke(obj, 0.0);
- return;
- } catch (IllegalAccessException | IllegalArgumentException
- | InvocationTargetException e) {
- LOGGER.error("{}", e);
- }
- }
- method = setter(obj, id, Integer.class);
+ method = setter(obj, id, 0, 0);
if (method != null) {
try {
method.invoke(obj, 0);
@@ -256,7 +247,7 @@
LOGGER.error("{}", e);
}
}
- method = setter(obj, id, Long.class);
+ method = setter(obj, id, 0L, 0);
if (method != null) {
try {
method.invoke(obj, 0L);
@@ -266,7 +257,7 @@
LOGGER.error("{}", e);
}
}
- method = setter(obj, id, IDto.class);
+ method = setter(obj, id, IDto.class, 0);
if (method != null) {
try {
method.invoke(obj, (Object[])null);
@@ -276,7 +267,7 @@
LOGGER.error("{}", e);
}
}
- method = setter(obj, id, Date.class);
+ method = setter(obj, id, Date.class, 0);
if (method != null) {
try {
method.invoke(obj, (Date)null);
@@ -286,7 +277,7 @@
LOGGER.error("{}", e);
}
}
- method = setter(obj, id, DateTime.class);
+ method = setter(obj, id, DateTime.class, 0);
if (method != null) {
try {
method.invoke(obj, (DateTime)null);
@@ -297,6 +288,4 @@
}
}
}
-
- abstract public void init();
}
diff --git a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/POSServiceBinder.java b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/POSServiceBinder.java
index 26f2e2a..9772603 100644
--- a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/POSServiceBinder.java
+++ b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/POSServiceBinder.java
@@ -11,9 +11,11 @@
* Loetz GmbH & Co. KG
*
*/
- package org.eclipse.osbp.abstractstatemachine;
+package org.eclipse.osbp.abstractstatemachine;
+import org.eclipse.osbp.runtime.common.session.ISessionManager;
import org.eclipse.osbp.ui.api.pos.IPOSService;
+import org.eclipse.osbp.ui.api.pos.ISignatureService;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
@@ -26,20 +28,52 @@
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger("servicebinder");
- public static IPOSService posService;
+ private static IPOSService posService;
+ private static ISessionManager sessionManager;
+ private static ISignatureService signatureService;
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
public void bindPOSService(IPOSService posService) {
- LOGGER.debug(POSServiceBinder.class.getCanonicalName()+" bound");
+ LOGGER.debug("FSM POSService bound");
POSServiceBinder.posService = posService;
}
public void unbindPOSService(IPOSService posService) {
- LOGGER.debug(POSServiceBinder.class.getCanonicalName() + " unbound");
+ LOGGER.debug("FSM POSService unbound");
POSServiceBinder.posService = null;
}
public static IPOSService getPosService() {
return posService;
}
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
+ public synchronized void bindSessionManager(final ISessionManager sessionManager) {
+ POSServiceBinder.sessionManager = sessionManager;
+ LOGGER.debug("FSM SessionManager bound");
+ }
+
+ public synchronized void unbindSessionManager(final ISessionManager sessionManager) {
+ POSServiceBinder.sessionManager = null;
+ LOGGER.debug("FSM SessionManager unbound");
+ }
+
+ public static ISessionManager getSessionManager() {
+ return sessionManager;
+ }
+
+ @Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.STATIC)
+ public synchronized void bindSignatureService(final ISignatureService signatureService) {
+ POSServiceBinder.signatureService = signatureService;
+ LOGGER.debug("FSM SignatureService bound");
+ }
+
+ public synchronized void unbindSignatureService(final ISignatureService signatureService) {
+ POSServiceBinder.signatureService = null;
+ LOGGER.debug("FSM SignatureService unbound");
+ }
+
+ public static ISignatureService getSignatureService() {
+ return signatureService;
+ }
}
diff --git a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/TaskEventSource.java b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/TaskEventSource.java
index e89fe9f..64b1979 100644
--- a/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/TaskEventSource.java
+++ b/org.eclipse.osbp.abstractstatemachine/src/org/eclipse/osbp/abstractstatemachine/TaskEventSource.java
@@ -11,7 +11,7 @@
* Loetz GmbH & Co. KG
*
*/
- package org.eclipse.osbp.abstractstatemachine;
+package org.eclipse.osbp.abstractstatemachine;
import java.util.TimerTask;
diff --git a/pom.xml b/pom.xml
index 070b679..4737ac9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,22 +65,17 @@
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
- <filters>
- <filter>
- <type>eclipse-plugin</type>
- <id>org.apache.aries.transaction.manager</id>
- <restrictTo>
- <!-- use a range that does not exist, we can not mix removeall and versionRange -->
- <versionRange>[0.5.0,0.5.1)</versionRange>
- </restrictTo>
- </filter>
- </filters>
<resolver>p2</resolver>
<pomDependencies>consider</pomDependencies>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>