public Attribute setText(String text) { attr.setAttributeValue(text); return this; }
private void updateFontAttributes(OMElement fontElement, FontStyleDTO style) { fontElement.getAttribute(new QName("fontName")). setAttributeValue(style.getFontName()); fontElement.getAttribute(new QName("size")). setAttributeValue(String.valueOf(style.getFontSize())); fontElement.getAttribute(new QName("isBold")). setAttributeValue(String.valueOf(style.isBold())); fontElement.getAttribute(new QName("isItalic")). setAttributeValue(String.valueOf(style.isItalic())); fontElement.getAttribute(new QName("isUnderline")). setAttributeValue(String.valueOf(style.isUnderLine())); fontElement.getAttribute(new QName("isStrikeThrough")). setAttributeValue(String.valueOf(style.isStrikeThough())); }
private void updateSubReportPosition(OMElement subReportElement, int yPos) throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:reportElement"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); List nodeList = xpathExpression.selectNodes(subReportElement); OMElement repElement = (OMElement) nodeList.get(0); repElement.getAttribute(new QName("y")).setAttributeValue(String.valueOf(yPos)); }
private void handleReportName() { OMElement documentElement = document.getOMDocumentElement(); documentElement.getAttribute(new QName("name")).setAttributeValue(report.getReportName()); }
private void handleTableOutlines() throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:style//a:box//a:pen"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement penElement = (OMElement) nodeList.get(0); penElement.getAttribute(new QName("lineWidth")).setAttributeValue(String.format("%.1g%n", tableReport.getOutLineThickness())); penElement.getAttribute(new QName("lineColor")).setAttributeValue(tableReport.getOutLineColor()); }
private void addParam(String dsname, String className) throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:parameter"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement element = (OMElement) nodeList.get(0); OMElement newParam = element.cloneOMElement(); newParam.getAttribute(new QName("name")).setAttributeValue(dsname); newParam.getAttribute(new QName("class")).setAttributeValue(className); documentElement.addChild(newParam); }
void updateDisplayName(OMElement classification, String displayName) { OMElement nameElement = XmlUtil.firstChildWithLocalName(classification, "Name"); if (nameElement == null) return; OMElement localizedStringElement = XmlUtil.firstChildWithLocalName(nameElement, "LocalizedString"); if (localizedStringElement == null) return; localizedStringElement.getAttribute(valueQName).setAttributeValue(displayName); }
private void replaceElement(TemplateEndpoint templateEndpoint, OMElement element) { Iterator attributesItr = element.getAllAttributes(); while (attributesItr.hasNext()) { OMAttribute attribute = (OMAttribute) attributesItr.next(); String replace = replace(attribute.getAttributeValue(), templateEndpoint); if (replace != null) { attribute.setAttributeValue(replace); } } if (element.getText() != null && !"".equals(element.getText())) { String replace = replace(element.getText(), templateEndpoint); if (replace != null) { element.setText(replace); } } Iterator elemItr = element.getChildElements(); while (elemItr.hasNext()) { OMElement childElement = (OMElement) elemItr.next(); replaceElement(templateEndpoint, childElement); } }
protected void handleBackgroundColor() throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:background//a:band//a:staticText//a:reportElement"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement element = (OMElement) nodeList.get(0); element.getAttribute(new QName("backcolor")).setAttributeValue(report.getBackgroundColour()); }
private void handleChartBackgroundColor(String chartText) throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:title//a:band//a:" + chartText + "//a:chart//a:reportElement"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement element = (OMElement) nodeList.get(0); element.getAttribute(new QName("backcolor")).setAttributeValue(chart.getChartBackColor()); }
private static OMElement updateWSDLImports(OMElement omElement,boolean isMasterArtifact) throws JaxenException { AXIOMXPath xPath = new AXIOMXPath("//wsd:import[@location]"); xPath.addNamespace("wsd", "http://schemas.xmlsoap.org/wsdl/"); Object result = xPath.evaluate(omElement); if(!(result instanceof ArrayList)){ return omElement; } List list = (ArrayList) result; for (Object obj : list) { OMElement _import = (OMElement) obj; OMAttribute attribute = _import.getAttribute(new QName("location")); String newValue = isMasterArtifact ? "dependencies" + attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")) :attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")+1); attribute.setAttributeValue(newValue); } return omElement; }
private static OMElement updateSchemaImports(OMElement omElement, boolean isMasterArtifact, String xpath) throws JaxenException { AXIOMXPath xPath = new AXIOMXPath(xpath); // "http://schemas.xmlsoap.org/wsdl/" xPath.addNamespace("xs", "http://www.w3.org/2001/XMLSchema"); Object result = xPath.evaluate(omElement); if(!(result instanceof ArrayList)){ return omElement; } List list = (ArrayList)result; for (Object obj : list) { OMElement _import = (OMElement) obj; OMAttribute attribute = _import.getAttribute(new QName("schemaLocation")); String newValue = isMasterArtifact ? "dependencies" + attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")) :attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")+1); attribute.setAttributeValue(newValue); } return omElement; }
public <T extends Element> T setAttributeValue(QName qname, String value) { OMAttribute attr = this.getAttribute(qname); if (attr != null && value != null) { attr.setAttributeValue(value); } else { if (value != null) { String uri = qname.getNamespaceURI(); String prefix = qname.getPrefix(); if (uri != null) { OMNamespace ns = findNamespace(uri, prefix); if (ns == null) ns = factory.createOMNamespace(uri, prefix); attr = factory.createOMAttribute(qname.getLocalPart(), ns, value); } else { attr = factory.createOMAttribute(qname.getLocalPart(), null, value); } if (attr != null) addAttribute(attr); } else if (attr != null) { removeAttribute(attr); } } return (T)this; }
private void updateTableTextAlignment() throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:title//a:band//a:componentElement//b:table//b:column" + "//a:textElement"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); xpathExpression.addNamespace("b", "http://jasperreports.sourceforge.net/jasperreports/components"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); int colNo = 0; for (int i = 0; i < nodeList.size(); i++) { OMElement textElement = (OMElement) nodeList.get(i); textElement.getAttribute(new QName("textAlignment")).setAttributeValue(tableReport.getColumns()[colNo]. getColumHeader().getAlignment()); i++; textElement = (OMElement) nodeList.get(i); textElement.getAttribute(new QName("textAlignment")).setAttributeValue(tableReport.getColumns()[colNo]. getColumnFooter().getAlignment()); i++; textElement = (OMElement) nodeList.get(i); textElement.getAttribute(new QName("textAlignment")).setAttributeValue(tableReport.getColumns()[colNo]. getTableCell().getAlignment()); colNo++; } }
/** * @param attributeName * @param attrValue * @param soapEnvelopeNamespaceURI */ protected void setAttribute(String attributeName, String attrValue, String soapEnvelopeNamespaceURI) { OMAttribute omAttribute = this.getAttribute( new QName(soapEnvelopeNamespaceURI, attributeName)); if (omAttribute != null) { omAttribute.setAttributeValue(attrValue); } else { OMAttribute attribute = new AttrImpl(this.ownerNode, attributeName, new NamespaceImpl(soapEnvelopeNamespaceURI, SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX), attrValue, this.factory); this.addAttribute(attribute); } }
private void deployOutSequence(WebApp api, int tenantId, String tenantDomain, Environment environment) throws AppManagementException, AxisFault { String outSeqExt = AppManagerUtil.getSequenceExtensionName(api) + "--Out"; String outSequenceName = api.getOutSequence(); OMElement outSequence = AppManagerUtil.getCustomSequence(outSequenceName, tenantId, "out"); AppGatewayAdminClient appGatewayAdminClient = new AppGatewayAdminClient(api.getId(), environment); if (outSequence != null) { outSequence.getAttribute(new QName("name")).setAttributeValue(outSeqExt); appGatewayAdminClient.addSequence(outSequence, tenantDomain); } }
private void deployInSequence(WebApp api, int tenantId, String tenantDomain, Environment environment) throws AppManagementException, AxisFault { String inSeqExt = AppManagerUtil.getSequenceExtensionName(api) + "--In"; String inSequenceName = api.getInSequence(); OMElement inSequence = AppManagerUtil.getCustomSequence(inSequenceName, tenantId, "in"); AppGatewayAdminClient appGatewayAdminClient = new AppGatewayAdminClient(api.getId(), environment); if (inSequence != null) { inSequence.getAttribute(new QName("name")).setAttributeValue(inSeqExt); appGatewayAdminClient.addSequence(inSequence, tenantDomain); } }
private void handleFields() throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:subDataset//a:field"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement aField = (OMElement) nodeList.get(0); int reportFields = nodeList.size(); int requiredFields = tableReport.getColumns().length; xpathExpression = new AXIOMXPath("//a:subDataset"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); xpathExpression.addNamespace("b", "http://jasperreports.sourceforge.net/jasperreports/components"); nodeList = xpathExpression.selectNodes(documentElement); OMElement subDatasetNode = (OMElement) nodeList.get(0); int additionalFields = requiredFields - reportFields; for (int i = 0; i < additionalFields; i++) { OMElement anotherField = aField.cloneOMElement(); anotherField.getAttribute(new QName("name")).setAttributeValue(String.valueOf(reportFields + i + 1)); subDatasetNode.addChild(anotherField); } }
public void setLocationPrefix(String prefix) { OMElement ele = registryErrorList(); for (OMElement e : XmlUtil.decendentsWithLocalName(ele, "RegistryError")) { OMAttribute at = e.getAttribute(MetadataSupport.location_qname); if (at == null) { at = MetadataSupport.om_factory.createOMAttribute("location", null, ""); e.addAttribute(at); } at.setAttributeValue(prefix + at.getAttributeValue()); } }
void updateClassification(OMElement classification, Code code) { classification.getAttribute(nodeRepresentationQName).setAttributeValue(code.getCode()); OMElement codeSystemElement = codeSystemElement(classification); if (codeSystemElement != null) codeSystemElement.setText(code.getScheme()); updateDisplayName(classification, code.getDisplay()); }