List of usage examples for javax.xml.namespace QName QName
public QName(String localPart)
QName
constructor specifying the local part.
If the local part is null
an IllegalArgumentException
is thrown.
From source file:hydrograph.ui.engine.ui.converter.impl.OutputXMLUiConverter.java
@Override protected Object getSchema(TypeOutputInSocket outSocket) { LOGGER.debug("Generating UI-Schema data for {}", componentName); Schema schema = null;//from w w w. j a v a 2 s.co m List<GridRow> gridRowList = new ArrayList<>(); ConverterUiHelper converterUiHelper = new ConverterUiHelper(uiComponent); if (outSocket.getSchema() != null && outSocket.getSchema().getFieldOrRecordOrIncludeExternalSchema().size() != 0) { schema = new Schema(); for (Object record : outSocket.getSchema().getFieldOrRecordOrIncludeExternalSchema()) { if ((TypeExternalSchema.class).isAssignableFrom(record.getClass())) { schema.setIsExternal(true); if (((TypeExternalSchema) record).getUri() != null) { schema.setExternalSchemaPath(((TypeExternalSchema) record).getUri()); } gridRowList.addAll(converterUiHelper.loadSchemaFromExternalFile(schema.getExternalSchemaPath(), Constants.XPATH_GRID_ROW)); schema.setGridRow(gridRowList); } else { TypeBaseField typeBaseField = (TypeBaseField) record; XPathGridRow xPathGridRow = new XPathGridRow(); converterUiHelper.getCommonSchema(xPathGridRow, typeBaseField); xPathGridRow.setXPath(typeBaseField.getOtherAttributes() .get(new QName(Constants.ABSOLUTE_OR_RELATIVE_XPATH_QNAME))); gridRowList.add(xPathGridRow); schema.setGridRow(gridRowList); schema.setIsExternal(false); } } } return schema; }
From source file:org.apache.servicemix.jms.JmsConsumerEndpointTest.java
public void testDurableConsumerDefault() throws Exception { JmsComponent component = new JmsComponent(); JmsConsumerEndpoint endpoint = new JmsConsumerEndpoint(); endpoint.setService(new QName("jms")); endpoint.setEndpoint("endpoint"); endpoint.setTargetService(new QName("receiver")); endpoint.setListenerType("default"); endpoint.setConnectionFactory(connectionFactory); endpoint.setPubSubDomain(true);/*from w w w . j ava2 s .c o m*/ endpoint.setSubscriptionDurable(true); endpoint.setClientId("clientId"); endpoint.setDestinationName("destinationTopic"); endpoint.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONNECTION); component.setEndpoints(new JmsConsumerEndpoint[] { endpoint }); container.activateComponent(component, "servicemix-jms"); Thread.sleep(500); container.start(); JmsTemplate jmsTemplate = new JmsTemplate(); jmsTemplate.setConnectionFactory(new PooledConnectionFactory(connectionFactory)); jmsTemplate.setPubSubDomain(true); jmsTemplate.afterPropertiesSet(); jmsTemplate.convertAndSend("destinationTopic", "<hello>world</hello>"); receiver.getMessageList().assertMessagesReceived(1); Thread.sleep(500); }
From source file:hydrograph.ui.engine.ui.converter.impl.InputXmlUiConverter.java
@Override protected Object getSchema(TypeInputOutSocket outSocket) { LOGGER.debug("Generating UI-Schema data for {}", componentName); Schema schema = null;//w w w . j a v a2 s. c o m List<GridRow> gridRowList = new ArrayList<>(); ConverterUiHelper converterUiHelper = new ConverterUiHelper(uiComponent); if (outSocket.getSchema() != null && outSocket.getSchema().getFieldOrRecordOrIncludeExternalSchema().size() != 0) { schema = new Schema(); for (Object record : outSocket.getSchema().getFieldOrRecordOrIncludeExternalSchema()) { if ((TypeExternalSchema.class).isAssignableFrom(record.getClass())) { schema.setIsExternal(true); if (((TypeExternalSchema) record).getUri() != null) { schema.setExternalSchemaPath(((TypeExternalSchema) record).getUri()); } gridRowList.addAll(converterUiHelper.loadSchemaFromExternalFile(schema.getExternalSchemaPath(), Constants.XPATH_GRID_ROW)); schema.setGridRow(gridRowList); } else { TypeBaseField typeBaseField = (TypeBaseField) record; XPathGridRow xPathGridRow = new XPathGridRow(); converterUiHelper.getCommonSchema(xPathGridRow, typeBaseField); xPathGridRow.setXPath(typeBaseField.getOtherAttributes() .get(new QName(Constants.ABSOLUTE_OR_RELATIVE_XPATH_QNAME))); xPathGridRow.setAbsolutexPath( StringUtils.isNotBlank(xPathGridRow.getXPath()) ? xPathGridRow.getXPath() : ""); gridRowList.add(xPathGridRow); schema.setGridRow(gridRowList); schema.setIsExternal(false); } saveComponentOutputSchema(outSocket.getId(), gridRowList); } } return schema; }
From source file:org.socialhistoryservices.pid.dao.HandleDaoImplTest.java
@Test public void testCreateNewHandleAllParams() throws Exception { log.info("Create New Handle"); String pid = PidGenerator.getPid(na); final LocAttType locAttType = new LocAttType(); final LocationType locationType1 = new LocationType(); locationType1.setHref(resolveUrl + PidGenerator.getPid()); locationType1.setId("11"); locationType1.setCountry("gb"); locAttType.getLocation().add(locationType1); final LocationType locationType2 = new LocationType(); locationType2.setHref(resolveUrl + PidGenerator.getPid()); locationType2.setId("21"); locationType2.setCountry("nl"); locationType2.getOtherAttributes().put(new QName("a"), "b"); locAttType.getLocation().add(locationType2); final List<Handle> insertedHandles = handleDao.createNewHandle(na, getPidType(pid, resolveUrl, locAttType, null)); assertNotNull(insertedHandles);//from www .j a va 2 s . c o m LocAttType locAtt = null; while (insertedHandles.iterator().hasNext()) { Handle h = insertedHandles.iterator().next(); if (h.getIndex() == 1000) { locAtt = pidResourceService.getLocations(h); break; } } assertNotNull("Expected to see locations", locAtt); List<LocationType> locations = locAtt.getLocation(); assertEquals( "When a URL is added plus two locations, we must have three locations returned. The third location is the URL", 3, locations.size()); boolean hasUrl = false; for (LocationType location : locations) { if (location.getHref().equals(resolveUrl)) { hasUrl = true; assertEquals("The resolve URL's value must be identical to the supplied resolve url.", resolveUrl, location.getHref()); } } assertEquals("A default location was expected", true, hasUrl); }
From source file:hydrograph.ui.engine.converter.impl.GenerateRecordsConverter.java
private TypeBaseField getTypeBaseFieldsFromGenerateRecordsSchema( GenerateRecordSchemaGridRow generateRecordsSchemaGridRow) { TypeBaseField typeBaseField = new TypeBaseField(); typeBaseField.setName(generateRecordsSchemaGridRow.getFieldName()); for (FieldDataTypes fieldDataType : FieldDataTypes.values()) { if (fieldDataType.value().equalsIgnoreCase(generateRecordsSchemaGridRow.getDataTypeValue())) typeBaseField.setType(fieldDataType); }/*www.java 2 s .c o m*/ if (FieldDataTypes.JAVA_UTIL_DATE.value().equals(generateRecordsSchemaGridRow.getDataTypeValue()) && StringUtils.isNotBlank(generateRecordsSchemaGridRow.getDateFormat())) typeBaseField.setFormat(generateRecordsSchemaGridRow.getDateFormat()); if (generateRecordsSchemaGridRow.getDataTypeValue().equals(FieldDataTypes.JAVA_LANG_DOUBLE.value()) || generateRecordsSchemaGridRow.getDataTypeValue() .equals(FieldDataTypes.JAVA_MATH_BIG_DECIMAL.value()) || generateRecordsSchemaGridRow.getDataTypeValue().equals(FieldDataTypes.JAVA_LANG_FLOAT.value())) { for (ScaleTypeList scaleType : ScaleTypeList.values()) { if (scaleType.value().equalsIgnoreCase(generateRecordsSchemaGridRow.getScaleTypeValue())) typeBaseField.setScaleType(scaleType); } if (!generateRecordsSchemaGridRow.getScale().trim().isEmpty()) typeBaseField.setScale(Integer.parseInt(generateRecordsSchemaGridRow.getScale())); } if (StringUtils.isNotBlank(generateRecordsSchemaGridRow.getScale())) typeBaseField.setScale(Integer.parseInt(generateRecordsSchemaGridRow.getScale())); if (!generateRecordsSchemaGridRow.getPrecision().trim().isEmpty()) typeBaseField.setPrecision(Integer.parseInt(generateRecordsSchemaGridRow.getPrecision())); typeBaseField.setDescription(generateRecordsSchemaGridRow.getDescription()); if (StringUtils.isNotBlank(generateRecordsSchemaGridRow.getLength())) { typeBaseField.getOtherAttributes().put(new QName(Constants.LENGTH_QNAME), generateRecordsSchemaGridRow.getLength()); } if (StringUtils.isNotBlank(generateRecordsSchemaGridRow.getRangeFrom())) { typeBaseField.getOtherAttributes().put(new QName(Constants.RANGE_FROM_QNAME), generateRecordsSchemaGridRow.getRangeFrom()); } if (StringUtils.isNotBlank(generateRecordsSchemaGridRow.getRangeTo())) { typeBaseField.getOtherAttributes().put(new QName(Constants.RANGE_TO_QNAME), generateRecordsSchemaGridRow.getRangeTo()); } if (StringUtils.isNotBlank(generateRecordsSchemaGridRow.getDefaultValue())) { typeBaseField.getOtherAttributes().put(new QName(Constants.DEFAULT_VALUE_QNAME), generateRecordsSchemaGridRow.getDefaultValue()); } return typeBaseField; }
From source file:com.predic8.membrane.core.multipart.XOPReconstitutor.java
private byte[] fillInXOPParts(InputStream inputStream, HashMap<String, Part> parts) throws XMLStreamException, FactoryConfigurationError { ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLEventWriter writer = XMLOutputFactory.newInstance().createXMLEventWriter(baos); try {/*from w w w . j av a2 s . c o m*/ XMLEventReader parser = createEventReaderFromStream(inputStream); boolean xopIncludeOpen = false; while (parser.hasNext()) { XMLEvent event = parser.nextEvent(); if (event instanceof StartElement) { StartElement start = (StartElement) event; if (XOP_NAMESPACE_URI.equals(start.getName().getNamespaceURI()) && start.getName().getLocalPart().equals("Include")) { String href = start.getAttributeByName(new QName("href")).getValue(); if (href.startsWith("cid:")) href = href.substring(4); Part p = parts.get("<" + href + ">"); if (p == null) throw new RuntimeException("Did not find multipart with id " + href); writer.add(p.asXMLEvent()); xopIncludeOpen = true; continue; } } else if (event instanceof EndElement) { EndElement start = (EndElement) event; if (XOP_NAMESPACE_URI.equals(start.getName().getNamespaceURI()) && start.getName().getLocalPart().equals("Include") && xopIncludeOpen) { xopIncludeOpen = false; continue; } } writer.add(event); } writer.flush(); } catch (XMLStreamException e) { log.warn("Received not-wellformed XML."); return null; } return baos.toByteArray(); }