/** * Gets all of the custom properties from the artifact and returns them as a map. * @param artifact */ private static Map<String, String> getArtifactProperties(BaseArtifactType artifact) { Map<String, String> props = new HashMap<String, String>(); for (org.oasis_open.docs.s_ramp.ns.s_ramp_v1.Property property : artifact.getProperty()) props.put(property.getPropertyName(), property.getPropertyValue()); return props; }
/** * Gets the value of one of the s-ramp custom properties. * @param artifact the s-ramp artifact * @param propName the name of the custom property * @return the custom property value or null if not found */ public static String getCustomProperty(BaseArtifactType artifact, String propName) { String rval = null; List<Property> properties = artifact.getProperty(); for (Property prop : properties) { if (propName.equals(prop.getPropertyName())) { rval = prop.getPropertyValue(); break; } } return rval; }
/** * Gets the value of one of the s-ramp custom properties. * @param artifact the s-ramp artifact * @param propName the name of the custom property * @return the custom property value or null if not found */ public static String getCustomProperty(BaseArtifactType artifact, String propName) { String rval = null; List<Property> properties = artifact.getProperty(); for (Property prop : properties) { if (propName.equals(prop.getPropertyName())) { rval = prop.getPropertyValue(); break; } } return rval; }
/** * Gets all properties with names that begin with the given prefix. This is useful * if the artifact has a number of custom properties that all start with a common * domain specific prefix. * * @param artifact the s-ramp artifact * @param prefix the prefix of the properties searched * @return the map of custom properties that start by the prefix */ public static Map<String, String> getCustomPropertiesByPrefix(BaseArtifactType artifact, String prefix) { Map<String, String> result = new HashMap<String, String>(); List<Property> properties = artifact.getProperty(); for (Property prop : properties) { if (prop.getPropertyName().startsWith(prefix)) { result.put(prop.getPropertyName(), prop.getPropertyValue()); } } return result; } }
private void processProperties( final BaseArtifactType artifact, final Element element, final XPath xpath ) throws Exception { final NodeList props = (NodeList)query(xpath, element, Utils.getElementQueryString(Propertied.XmlId.PROPERTY), XPathConstants.NODESET); if (props.getLength() != 0) { LOGGER.debug("VdbManifestDeriver:processing '{}' properties", props.getLength()); //$NON-NLS-1$ for (int propIndex = 0, numProps = props.getLength(); propIndex < numProps; ++propIndex) { final Element prop = (Element)props.item(propIndex); final String name = prop.getAttribute(Propertied.XmlId.NAME); final String value = prop.getAttribute(Propertied.XmlId.VALUE); SrampModelUtils.setCustomProperty(artifact, name, value); } if (LOGGER.isDebugEnabled()) { for (final Property prop : artifact.getProperty()) { LOGGER.debug("VdbManifestDeriver:artifact '{}' has property '{}' with value '{}'", //$NON-NLS-1$ new Object[] {artifact.getName(), prop.getPropertyName(), prop.getPropertyValue()}); } } } }
/** * Updates the custom s-ramp properties. * @param artifact * @throws Exception */ private void updateArtifactProperties(BaseArtifactType artifact) throws Exception { for (org.oasis_open.docs.s_ramp.ns.s_ramp_v1.Property property : artifact.getProperty()) { createProperty(property.getPropertyName(), property.getPropertyValue(), true); } }
/** * Creates the artifact that should be included in the returned Entry. * @throws IllegalAccessException * @throws InstantiationException */ protected BaseArtifactType createIncludedArtifact(BaseArtifactType artifact) throws InstantiationException, IllegalAccessException { if (includeArtifact()) { BaseArtifactType includedArtifact = artifact.getClass().newInstance(); List<Property> properties = artifact.getProperty(); for (Property prop : properties) { if (this.propertyNames.contains(prop.getPropertyName())) { SrampModelUtils.setCustomProperty(includedArtifact, prop.getPropertyName(), prop.getPropertyValue()); } } return includedArtifact; } else { return null; } }
LOGGER.debug("VdbManifestDeriver:Source property '{}' with value '{}'", //$NON-NLS-1$ prop.getPropertyName(), prop.getPropertyValue());
LOGGER.debug("VdbManifestDeriver:Import VDB property '{}' with value '{}'", //$NON-NLS-1$ prop.getPropertyName(), prop.getPropertyValue());
LOGGER.debug("VdbManifestDeriver:data policy property '{}' with value '{}'", //$NON-NLS-1$ prop.getPropertyName(), prop.getPropertyValue()); LOGGER.debug("VdbManifestDeriver:Source property '{}' with value '{}'", //$NON-NLS-1$ prop.getPropertyName(), prop.getPropertyValue());
/** * Test method for {@link org.overlord.sramp.integration.switchyard.deriver.SwitchYardXmlDeriver#derive(java.util.Collection, org.s_ramp.xmlns._2010.s_ramp.BaseArtifactType, org.w3c.dom.Element, javax.xml.xpath.XPath)}. * @throws IOException */ @Test public void testJavaDeriver() throws IOException { MavenPomDeriver deriver = new MavenPomDeriver(); ExtendedDocument artifact = new ExtendedDocument(); artifact.setArtifactType(BaseArtifactEnum.EXTENDED_ARTIFACT_TYPE); artifact.setName("pom.xml"); //$NON-NLS-1$ InputStream is = getClass().getResourceAsStream("pom.xml"); //$NON-NLS-1$ // Derive @SuppressWarnings("unused") Collection<BaseArtifactType> derivedArtifacts = deriver.derive(artifact, is); is.close(); // Assert Assert.assertNotNull(artifact.getProperty()); for (Property property : artifact.getProperty()) { System.out.println(property.getPropertyName() + " - " + property.getPropertyValue()); } System.out.println(artifact.getDescription()); }
String p1 = artifact.getProperty().get(0).getPropertyName() + "=" + artifact.getProperty().get(0).getPropertyValue(); //$NON-NLS-1$ String p2 = artifact.getProperty().get(1).getPropertyName() + "=" + artifact.getProperty().get(1).getPropertyValue(); //$NON-NLS-1$ Set<String> ps = new HashSet<String>(); ps.add(p1); p1 = artifact.getProperty().get(0).getPropertyName() + "=" + artifact.getProperty().get(0).getPropertyValue(); //$NON-NLS-1$ p2 = artifact.getProperty().get(1).getPropertyName() + "=" + artifact.getProperty().get(1).getPropertyValue(); //$NON-NLS-1$ ps.clear(); ps.add(p1);
String p1 = artifact.getProperty().get(0).getPropertyName() + "=" + artifact.getProperty().get(0).getPropertyValue(); //$NON-NLS-1$ String p2 = artifact.getProperty().get(1).getPropertyName() + "=" + artifact.getProperty().get(1).getPropertyValue(); //$NON-NLS-1$ Set<String> ps = new HashSet<String>(); ps.add(p1); p1 = artifact.getProperty().get(0).getPropertyName() + "=" + artifact.getProperty().get(0).getPropertyValue(); //$NON-NLS-1$ p2 = artifact.getProperty().get(1).getPropertyName() + "=" + artifact.getProperty().get(1).getPropertyValue(); //$NON-NLS-1$ ps.clear(); ps.add(p1);
commandInvocation.getShell().out().println(Messages.i18n.format("PrintArtifact.CustomPropsHeading")); for (Property property : artifact.getProperty()) { printProperty(property.getPropertyName(), property.getPropertyValue());