use of com.google.api.ads.admanager.axis.v202111.Content in project jspwiki by apache.
the class MarkdownTheadDecorator method decorate.
/**
* {@inheritDoc}
*/
@Override
public void decorate(final Element element) throws JDOMException {
super.decorate(element);
final Content cNestedTr = element.getContent().get(0);
if (cNestedTr instanceof Element) {
final Element nestedTr = (Element) cNestedTr;
final int ths = nestedTr.getContent().size();
if (ths > 0) {
for (int i = 0; i < ths; i++) {
out.print("|---");
}
}
out.println();
}
}
use of com.google.api.ads.admanager.axis.v202111.Content in project mycore by MyCoRe-Org.
the class MCRXMLHelperTest method testList.
@Test
public void testList() throws Exception {
Element child1 = new Element("child").setText("Hallo Welt");
Element child2 = new Element("child").setText("hello world");
Element child3 = new Element("child").setText("Bonjour le monde");
List<Content> l1 = new ArrayList<>();
l1.add(child1);
l1.add(child2);
l1.add(child3);
Element root = new Element("root");
root.addContent(l1);
String formattedXML = "<root>\n<child>Hallo Welt</child>\n" + "<child>hello world</child>" + "<child>Bonjour le monde</child>\n</root>";
SAXBuilder b = new SAXBuilder();
Document doc = b.build(new ByteArrayInputStream(formattedXML.getBytes(Charset.forName("UTF-8"))));
assertEquals("Elements should be equal", true, MCRXMLHelper.deepEqual(root, doc.getRootElement()));
}
use of com.google.api.ads.admanager.axis.v202111.Content in project mycore by MyCoRe-Org.
the class MCRWCMSDefaultSectionProvider method getContent.
/**
* Returns the content of an element as string. The element itself
* is ignored.
*
* @param e the element to get the content from
* @return the content as string
*/
protected String getContent(Element e) throws IOException {
XMLOutputter out = new XMLOutputter();
StringWriter writer = new StringWriter();
for (Content child : e.getContent()) {
if (child instanceof Element) {
out.output((Element) child, writer);
} else if (child instanceof Text) {
Text t = (Text) child;
String trimmedText = t.getTextTrim();
if (!trimmedText.equals("")) {
Text newText = new Text(trimmedText);
out.output(newText, writer);
}
}
}
return writer.toString();
}
use of com.google.api.ads.admanager.axis.v202111.Content in project mycore by MyCoRe-Org.
the class MCRXSL2XMLTransformer method getDocument.
private Document getDocument(JDOMResult result) {
Document resultDoc = result.getDocument();
if (resultDoc == null) {
// Sometimes a transformation produces whitespace strings
// JDOM would produce a empty document if it detects those
// So we remove them, if they exists.
List<Content> transformResult = result.getResult();
int origSize = transformResult.size();
Iterator<Content> iterator = transformResult.iterator();
while (iterator.hasNext()) {
Content content = iterator.next();
if (content instanceof Text) {
String trimmedText = ((Text) content).getTextTrim();
if (trimmedText.length() == 0) {
iterator.remove();
}
}
}
if (transformResult.size() < origSize) {
JDOMFactory f = result.getFactory();
if (f == null) {
f = new DefaultJDOMFactory();
}
resultDoc = f.document(null);
resultDoc.setContent(transformResult);
}
}
return resultDoc;
}
use of com.google.api.ads.admanager.axis.v202111.Content in project mycore by MyCoRe-Org.
the class MCRMODSMetadataShareAgent method distributeMetadata.
/* (non-Javadoc)
* @see org.mycore.datamodel.metadata.share.MCRMetadataShareAgent#inheritMetadata(org.mycore.datamodel.metadata.MCRObject)
*/
@Override
public void distributeMetadata(MCRObject holder) throws MCRPersistenceException, MCRAccessException {
MCRMODSWrapper holderWrapper = new MCRMODSWrapper(holder);
List<MCRMetaLinkID> children = holder.getStructure().getChildren();
if (!children.isEmpty()) {
LOGGER.info("Update inherited metadata");
for (MCRMetaLinkID childIdRef : children) {
MCRObjectID childId = childIdRef.getXLinkHrefID();
if (MCRMODSWrapper.isSupported(childId)) {
LOGGER.info("Update: {}", childIdRef);
MCRObject child = MCRMetadataManager.retrieveMCRObject(childId);
MCRMODSWrapper childWrapper = new MCRMODSWrapper(child);
inheritToChild(holderWrapper, childWrapper);
LOGGER.info("Saving: {}", childIdRef);
try {
MCRMetadataManager.update(child);
} catch (MCRPersistenceException | MCRAccessException e) {
throw new MCRPersistenceException("Error while updating inherited metadata", e);
}
}
}
}
Collection<String> recipientIds = MCRLinkTableManager.instance().getSourceOf(holder.getId(), MCRLinkTableManager.ENTRY_TYPE_REFERENCE);
for (String rId : recipientIds) {
MCRObjectID recipientId = MCRObjectID.getInstance(rId);
if (MCRMODSWrapper.isSupported(recipientId)) {
LOGGER.info("distribute metadata to {}", rId);
MCRObject recipient = MCRMetadataManager.retrieveMCRObject(recipientId);
MCRMODSWrapper recipientWrapper = new MCRMODSWrapper(recipient);
for (Element relatedItem : recipientWrapper.getLinkedRelatedItems()) {
String holderId = relatedItem.getAttributeValue("href", MCRConstants.XLINK_NAMESPACE);
if (holder.getId().toString().equals(holderId)) {
@SuppressWarnings("unchecked") Filter<Content> sharedMetadata = (Filter<Content>) Filters.element("part", MCRConstants.MODS_NAMESPACE).negate();
relatedItem.removeContent(sharedMetadata);
relatedItem.addContent(holderWrapper.getMODS().cloneContent());
LOGGER.info("Saving: {}", recipientId);
try {
MCRMetadataManager.update(recipient);
} catch (MCRPersistenceException | MCRAccessException e) {
throw new MCRPersistenceException("Error while updating shared metadata", e);
}
}
}
}
}
}
Aggregations