/** * Gets all the EPCIS events matching the given filters from a given ECPIS repository. * * @param filters the EPC code * @param EPCISAddress the URL of the EPCIS repository * @return a list of EPCIS events * @throws RemoteException */ public List<EPCISEventType> queryEPCIS(Map<String, String> filters, String EPCISAddress) throws IoTaException { QueryEPCISRequest in = new QueryEPCISRequest(); in.setFilters(createQueryParams(filters)); in.setEPCISAddress(EPCISAddress); in.setIdentity(identity); QueryEPCISResponse out = port.queryEPCIS(in); return EPCISEventTypeHelper.listFromEventList(out.getEventList()); }
/** * Gets all the EPCIS events concerning a given EPC code. * * @param EPC the EPC code * @return a list of EPCIS events * @throws RemoteException */ public List<EPCISEventType> traceEPC(String epc) throws IoTaException { TraceEPCRequest in = new TraceEPCRequest(); EPC tepc = new EPC(); tepc.setValue(epc); in.setEpc(tepc); in.setIdentity(identity); TraceEPCResponse out = port.traceEPC(in); return EPCISEventTypeHelper.listFromEventList(out.getEventList()); }
/** * Gets all the EPCIS events concerning a given EPC code from a given ECPIS repository. * * @param EPC the EPC code * @param EPCISAddress the URL of the EPCIS repository * @return a list of EPCIS events * @throws RemoteException */ public List<EPCISEventType> queryEPCIS(String epc, String EPCISAddress) throws IoTaException { QueryEPCISRequest in = new QueryEPCISRequest(); EPC tepc = new EPC(); tepc.setValue(epc); in.setEpc(tepc); in.setEPCISAddress(EPCISAddress); in.setIdentity(identity); QueryEPCISResponse out = port.queryEPCIS(in); return EPCISEventTypeHelper.listFromEventList(out.getEventList()); }
/** * Gets all the EPCIS events sorted by EPCIS concerning a given EPC code. * * @param EPC the EPC code * @return a list of EPCIS events by EPCIS * @throws RemoteException */ public Map<String, List<EPCISEventType>> traceEPCByEPCIS(String epc) throws IoTaException { TraceEPCByEPCISRequest in = new TraceEPCByEPCISRequest(); EPC tepc = new EPC(); tepc.setValue(epc); in.setEpc(tepc); in.setIdentity(identity); TraceEPCByEPCISResponse out = port.traceEPCByEPCIS(in); Map<String, List<EPCISEventType>> results = new HashMap<String, List<EPCISEventType>>(); for (EventsByEPCIS eventsByEPCIS : out.getEventsByEPCIS()) { List<EPCISEventType> eventList = EPCISEventTypeHelper.listFromEventList(eventsByEPCIS.getEventList()); results.put(eventsByEPCIS.getEpcisAddress(), eventList); } return results; }
public static void main(String args[]) throws Exception { String service = "traceEPC"; String serviceURL = "https://localhost:8443/omega"; String epcisOrDsURL = null; String sid = "anonymous"; String epc = "urn:epc:id:sgtin:40000.00002.1298283877319"; String ksFile = null; String ksPass = null; String tsFile = null; String tsPass = null; switch (args.length) { case 8: case 9: ksFile = args[4]; ksPass = args[5]; tsFile = args[6]; tsPass = args[7]; // fall-through case 4: case 5: service = args[0]; serviceURL = args[1]; sid = args[2]; epc = args[3]; break; default: System.err.println( "Usage: OmICron <Service> <Service URL> <IDENTITY> <EPC URN ID> [<Keystore File> <Keystore Password> <Truststore file> <Truststore Password>] [<EPCIS or DS URL>]"); System.err.println(); System.err.println( "example: OmICron " + service + " " + serviceURL + " " + sid + " " + epc + " /srv/keystore.jks store_pw /srv/truststore.jks trust_pw"); System.err.println( "example: OmICron queryEPCIS " + serviceURL + " " + sid + " " + epc + " /srv/keystore.jks store_pw /srv/truststore.jks trust_pw https://localhost:8443/eta/ided_query"); System.exit(-1); break; } Identity id = new Identity(); id.setAsString(sid); List<EPCISEventType> eventList = null; List<DSEvent> dsEventList = null; if ("traceEPC".equals(service)) { System.out.println("Processing traceEPC ..."); OmICron client = new OmICron(id, serviceURL, ksFile, ksPass, tsFile, tsPass); eventList = client.traceEPC(epc); } else if ("queryEPCIS".equals(service)) { epcisOrDsURL = (args.length == 5) ? args[4] : args[8]; System.out.println("Processing queryEPCIS ..."); OmICron client = new OmICron(id, serviceURL, ksFile, ksPass, tsFile, tsPass); eventList = client.queryEPCIS(epc, epcisOrDsURL); } else if ("queryDS".equals(service)) { epcisOrDsURL = (args.length == 5) ? args[4] : args[8]; System.out.println("Processing queryDS ..."); OmICron client = new OmICron(id, serviceURL, ksFile, ksPass, tsFile, tsPass); dsEventList = client.queryDS(epc, epcisOrDsURL); } else { System.out.println("Service:"); System.out.println("traceEPC: gets all events concerning an EPC code"); System.out.println("queryEPCIS: gets events concerning an EPC code contained by an EPCIS"); System.exit(-1); } if (eventList != null && !eventList.isEmpty()) { for (EPCISEventType evt : eventList) { EPCISEventTypeHelper e = new EPCISEventTypeHelper(evt); System.out.println(" Event found:"); System.out.println(e.toString()); } } else if (dsEventList != null && !dsEventList.isEmpty()) { for (DSEvent event : dsEventList) { System.out.println("Event found: "); System.out.println(" | EPC: " + event.getEpc()); System.out.println(" | Event type: " + event.getEventType()); System.out.println(" | Business Step: " + event.getBizStep()); System.out.println(" | Event time: " + event.getEventTime().toXMLFormat()); System.out.println(" | Service type: " + event.getServiceType()); System.out.println(" | Service address: " + event.getServiceAddress()); } } else { System.out.println(" No event found."); } System.out.println("Bye."); }