use of javax.xml.bind.JAXBElement in project midpoint by Evolveum.
the class Upload method unmarshalFile.
private static Object unmarshalFile(File file) throws JAXBException, FileNotFoundException {
JAXBContext jc = ModelClientUtil.instantiateJaxbContext();
Unmarshaller unmarshaller = jc.createUnmarshaller();
Object o = unmarshaller.unmarshal(new FileInputStream(file));
if (o instanceof JAXBElement) {
return ((JAXBElement) o).getValue();
} else {
return o;
}
}
use of javax.xml.bind.JAXBElement in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method dumpAttributes.
protected void dumpAttributes(ShadowType shadowType) {
ShadowAttributesType attributes = shadowType.getAttributes();
System.out.println("Attributes for " + shadowType.getObjectClass().getLocalPart() + " " + getOrig(shadowType.getName()) + " {" + attributes.getAny().size() + " entries):");
for (Object item : attributes.getAny()) {
if (item instanceof Element) {
Element e = (Element) item;
System.out.println(" - " + e.getLocalName() + ": " + e.getTextContent());
} else if (item instanceof JAXBElement) {
JAXBElement je = (JAXBElement) item;
String typeInfo = je.getValue() instanceof String ? "" : (" (" + je.getValue().getClass().getSimpleName() + ")");
System.out.println(" - " + je.getName().getLocalPart() + ": " + je.getValue() + typeInfo);
} else {
System.out.println(" - " + item);
}
}
}
use of javax.xml.bind.JAXBElement in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method getAttributesAsMap.
protected Map<String, Object> getAttributesAsMap(ShadowType shadowType) {
Map<String, Object> rv = new HashMap<>();
ShadowAttributesType attributes = shadowType.getAttributes();
for (Object item : attributes.getAny()) {
if (item instanceof Element) {
Element e = (Element) item;
put(rv, e.getLocalName(), e.getTextContent());
} else if (item instanceof JAXBElement) {
JAXBElement je = (JAXBElement) item;
put(rv, je.getName().getLocalPart(), je.getValue());
} else {
// nothing to do here
}
}
return rv;
}
use of javax.xml.bind.JAXBElement in project ddf by codice.
the class TestCswFilterDelegate method testFeatureIdOr.
@Test
public void testFeatureIdOr() throws JAXBException, SAXException, IOException, XpathException {
ObjectFactory filterObjectFactory = new ObjectFactory();
FeatureIdType fidType = new FeatureIdType();
fidType.setFid("cswRecord.1234");
List<JAXBElement<? extends AbstractIdType>> fidFilters = new ArrayList<>();
fidFilters.add(filterObjectFactory.createFeatureId(fidType));
FilterType idFilter = new FilterType();
idFilter.setId(fidFilters);
FeatureIdType fidType2 = new FeatureIdType();
fidType2.setFid("cswRecord.5678");
List<JAXBElement<? extends AbstractIdType>> fidFilters2 = new ArrayList<>();
fidFilters2.add(filterObjectFactory.createFeatureId(fidType2));
FilterType idFilter2 = new FilterType();
idFilter2.setId(fidFilters2);
List<FilterType> filters = new ArrayList<>();
filters.add(idFilter);
filters.add(idFilter2);
FilterType filterType = cswFilterDelegateLatLon.or(filters);
String xml = getXmlFromMarshaller(filterType);
assertXpathExists("/ogc:Filter/ogc:FeatureId[@fid='cswRecord.1234']", xml);
assertXpathExists("/ogc:Filter/ogc:FeatureId[@fid='cswRecord.5678']", xml);
}
use of javax.xml.bind.JAXBElement in project ddf by codice.
the class TestCswFilterDelegate method testFeatureIdAndComparisonOpsOr.
@Test(expected = UnsupportedOperationException.class)
public void testFeatureIdAndComparisonOpsOr() throws JAXBException, SAXException, IOException {
ObjectFactory filterObjectFactory = new ObjectFactory();
FeatureIdType fidType = new FeatureIdType();
fidType.setFid("cswRecord.1234");
List<JAXBElement<? extends AbstractIdType>> fidFilters = new ArrayList<>();
fidFilters.add(filterObjectFactory.createFeatureId(fidType));
FilterType idFilter = new FilterType();
idFilter.setId(fidFilters);
FilterType propertyIsLikeFilter = cswFilterDelegateLatLon.propertyIsLike(propertyName, likeLiteral, isCaseSensitive);
List<FilterType> filterList = new ArrayList<>();
filterList.add(idFilter);
filterList.add(propertyIsLikeFilter);
cswFilterDelegateLatLon.or(filterList);
}
Aggregations