/** * (nkef) Delete a vocabulary's Element Attribute. * * @param vocabularyType * @param vocabularyURI * @param vocabularyAttribute * @param vocabularyAttributeValue * @return true if the method Succeeds false otherwise * @param vocabularyType * @param vocabularyURI * @param vocabularyAttributes ArrayList<String> * @return true if the method Succeeds false otherwise */ public boolean simpleMasterDataAttributeMassDelete( String vocabularyType, String vocabularyURI, ArrayList<String> vocabularyAttributeIDs) { try { VocabularyType vocabulary = new VocabularyType(); VocabularyElementListType vocabularyElementList = new VocabularyElementListType(); VocabularyListType vocabularyList = new VocabularyListType(); vocabulary.setType(vocabularyType); VocabularyElementType vocabularyElement = new VocabularyElementType(); vocabularyElement.setId(vocabularyURI); for (String vocabularyAttribute : vocabularyAttributeIDs) { AttributeType attribute = new AttributeType(); if (vocabularyAttribute.startsWith("urn:epcglobal:epcis:mda:")) { attribute.setId(vocabularyAttribute); } else { attribute.setId("urn:epcglobal:epcis:mda:" + vocabularyAttribute); } attribute.getOtherAttributes().put(new QName("mode"), "3"); attribute.getOtherAttributes().put(new QName("value"), "null"); vocabularyElement.getAttribute().add(attribute); } vocabularyElementList.getVocabularyElement().add(vocabularyElement); vocabulary.setVocabularyElementList(vocabularyElementList); vocabularyList.getVocabulary().add(vocabulary); EPCISMasterDataDocumentType epcisMasterDataDoc = new EPCISMasterDataDocumentType(); EPCISMasterDataBodyType epcisMasterDataBody = new EPCISMasterDataBodyType(); epcisMasterDataBody.setVocabularyList(vocabularyList); epcisMasterDataDoc.setEPCISBody(epcisMasterDataBody); epcisMasterDataDoc.setSchemaVersion(new BigDecimal("1.0")); epcisMasterDataDoc.setCreationDate(getCurrentTime()); int httpResponseCode = this.capture(epcisMasterDataDoc); if (httpResponseCode != 200) { log.debug("The Master Data could NOT be captured!\n"); return false; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } return true; }
/** * (nkef) Insert, many vocabulary's Elements . * * @param vocabularyType * @param vocabularyElementURIs ArrayList<String> * @return true if the method Succeeds false otherwise */ public boolean simpleMasterDataMassInsert( String vocabularyType, ArrayList<String> vocabularyElementURIs) { try { VocabularyType vocabulary = new VocabularyType(); VocabularyElementListType vocabularyElementList = new VocabularyElementListType(); VocabularyListType vocabularyList = new VocabularyListType(); vocabulary.setType(vocabularyType); for (String vocabularyElementURI : vocabularyElementURIs) { VocabularyElementType vocabularyElement = new VocabularyElementType(); vocabularyElement.setId(vocabularyElementURI); vocabularyElement.getOtherAttributes().put(new QName("mode"), "1"); vocabularyElementList.getVocabularyElement().add(vocabularyElement); } vocabulary.setVocabularyElementList(vocabularyElementList); vocabularyList.getVocabulary().add(vocabulary); EPCISMasterDataDocumentType epcisMasterDataDoc = new EPCISMasterDataDocumentType(); EPCISMasterDataBodyType epcisMasterDataBody = new EPCISMasterDataBodyType(); epcisMasterDataBody.setVocabularyList(vocabularyList); epcisMasterDataDoc.setEPCISBody(epcisMasterDataBody); epcisMasterDataDoc.setSchemaVersion(new BigDecimal("1.0")); epcisMasterDataDoc.setCreationDate(getCurrentTime()); int httpResponseCode = this.capture(epcisMasterDataDoc); if (httpResponseCode != 200) { log.debug("The Master Data could NOT be captured!\n"); return false; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } return true; }
/** * (nkef) Insert or Update a vocabulary's Element Attribute. If the Vocabulary is not inserted yet * it will be inserted. The vocabularyURI, vocabularyAttribute pair should be unique so if it * already exists it will be changed to the vocabularyAttribute entered or simply rewrite it. * * @param vocabularyType * @param vocabularyURI * @param vocabularyAttribute * @param vocabularyAttributeValue * @return true if the method Succeeds false otherwise */ public boolean simpleMasterDataAndAttributeInsertOrAlter( String vocabularyType, String vocabularyURI, String vocabularyAttribute, String vocabularyAttributeValue) { try { VocabularyType vocabulary = new VocabularyType(); VocabularyElementListType vocabularyElementList = new VocabularyElementListType(); VocabularyListType vocabularyList = new VocabularyListType(); vocabulary.setType(vocabularyType); VocabularyElementType vocabularyElement = new VocabularyElementType(); vocabularyElement.setId(vocabularyURI); // vocabularyElement.getOtherAttributes().put(new QName("mode"), // "1"); AttributeType attribute = new AttributeType(); if (vocabularyAttribute.startsWith("urn:epcglobal:epcis:mda:")) { attribute.setId(vocabularyAttribute); } else { attribute.setId("urn:epcglobal:epcis:mda:" + vocabularyAttribute); } // attribute.getOtherAttributes().put(new QName("mode"), mode); // Element attributeTypeElement = null; // try { // DocumentBuilderFactory dbf = // DocumentBuilderFactory.newInstance(); // DocumentBuilder db; // db = dbf.newDocumentBuilder(); // Document document = db.newDocument(); // attributeTypeElement = // document.createElement("attributeTypeElement"); // attributeTypeElement.setAttribute("attribute", // vocabularyAttributeValue); // } // catch (ParserConfigurationException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // attribute.getAny().add(attributeTypeElement); attribute.getOtherAttributes().put(new QName("value"), vocabularyAttributeValue); vocabularyElement.getAttribute().add(attribute); vocabularyElementList.getVocabularyElement().add(vocabularyElement); vocabulary.setVocabularyElementList(vocabularyElementList); vocabularyList.getVocabulary().add(vocabulary); EPCISMasterDataDocumentType epcisMasterDataDoc = new EPCISMasterDataDocumentType(); EPCISMasterDataBodyType epcisMasterDataBody = new EPCISMasterDataBodyType(); epcisMasterDataBody.setVocabularyList(vocabularyList); epcisMasterDataDoc.setEPCISBody(epcisMasterDataBody); epcisMasterDataDoc.setSchemaVersion(new BigDecimal("1.0")); epcisMasterDataDoc.setCreationDate(getCurrentTime()); int httpResponseCode = this.capture(epcisMasterDataDoc); if (httpResponseCode != 200) { log.debug("The Master Data could NOT be captured!\n"); return false; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } return true; }