Java Code Examples for org.jdom.Element#getParentElement()

The following examples show how to use org.jdom.Element#getParentElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EDocLiteDatabasePostProcessor.java    From rice with Educational Community License v2.0 6 votes vote down vote up
private List setExtractFields(Document documentContent) {
    Element rootElement = getRootElement(documentContent);
    List<Element> fields = new ArrayList<Element>();
    Collection<Element> fieldElements = XmlHelper.findElements(rootElement, "field");
    Iterator<Element> elementIter = fieldElements.iterator();
    while (elementIter.hasNext()) {
        Element field = elementIter.next();
        Element version = field.getParentElement();
        if (version.getAttribute("current").getValue().equals("true")) {
            if (field.getAttribute("name") != null) {
                fields.add(field);
            }
        }
    }
    return fields;
}
 
Example 2
Source File: JDOMNamespaceContext.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static String rawGetPrefix(Element element, String namespaceURI) {
    if (element.getNamespaceURI().equals(namespaceURI)) {
        return element.getNamespacePrefix();
    }

    List<?> namespaces = element.getAdditionalNamespaces();

    for (Iterator<?> itr = namespaces.iterator(); itr.hasNext();) {
        Namespace ns = (Namespace)itr.next();

        if (ns.getURI().equals(namespaceURI)) {
            return ns.getPrefix();
        }
    }

    if (element.getParentElement() != null) {
        return rawGetPrefix(element.getParentElement(), namespaceURI);
    }
    return null;
}
 
Example 3
Source File: JDOMNamespaceContext.java    From cxf with Apache License 2.0 6 votes vote down vote up
static void rawGetPrefixes(Element element, String namespaceURI, List<String> prefixes) {
    if (element.getNamespaceURI().equals(namespaceURI)) {
        prefixes.add(element.getNamespacePrefix());
    }

    List<?> namespaces = element.getAdditionalNamespaces();

    for (Iterator<?> itr = namespaces.iterator(); itr.hasNext();) {
        Namespace ns = (Namespace)itr.next();

        if (ns.getURI().equals(namespaceURI)) {
            prefixes.add(ns.getPrefix());
        }
    }

    if (element.getParentElement() != null) {
        rawGetPrefixes(element.getParentElement(), namespaceURI, prefixes);
    }
}
 
Example 4
Source File: FYIByNetworkId.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public SimpleResult process(RouteContext context, RouteHelper helper)
		throws Exception {

       LOG.debug("processing FYIByNetworkId simple node");
       String documentId = context.getDocument().getDocumentId();
       Element rootElement = getRootElement(new StandardDocumentContent(context.getDocument().getDocContent()));
	Collection<Element> fieldElements = XmlHelper.findElements(rootElement, "field");
       Iterator<Element> elementIter = fieldElements.iterator();
       while (elementIter.hasNext()) {
       	Element field = (Element) elementIter.next();
       	Element version = field.getParentElement();
       	if (version.getAttribute("current").getValue().equals("true")) {
       		LOG.debug("Looking for networkId field:  " + field.getAttributeValue("name"));
              	if (field.getAttribute("name")!= null && field.getAttributeValue("name").equals("networkId")) {
           		LOG.debug("Should send an FYI to netID:  " + field.getChildText("value"));
              		if (field.getChildText("value") != null) {
              			Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(field.getChildText("value"));

              			//WorkflowDocument wfDoc = new WorkflowDocument(new NetworkIdVO(field.getChildText("value")), documentId);
              			if (!context.isSimulation()) {
                  			KEWServiceLocator.getWorkflowDocumentService().adHocRouteDocumentToPrincipal(user.getPrincipalId(), context.getDocument(), KewApiConstants.ACTION_REQUEST_FYI_REQ, null, null, "Notification Request", user.getPrincipalId(), "Notification Request", true, null);
              		}
              			//wfDoc.adHocRouteDocumentToPrincipal(KewApiConstants.ACTION_REQUEST_FYI_REQ, "Notification Request", new NetworkIdVO(field.getChildText("value")), "Notification Request", true);
               		LOG.debug("Sent FYI using the adHocRouteDocumentToPrincipal function to NetworkID:  " + user.getPrincipalName());
                              	break;
              	}
       	}
       }
       }
	return super.process(context, helper);
}
 
Example 5
Source File: FYIByUniversityId.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public SimpleResult process(RouteContext context, RouteHelper helper)
		throws Exception {

       LOG.debug("processing FYIByUniversityId node");
       Element rootElement = getRootElement(new StandardDocumentContent(context.getDocument().getDocContent()));
		Collection<Element> fieldElements = XmlHelper.findElements(rootElement, "field");
       Iterator<Element> elementIter = fieldElements.iterator();
       while (elementIter.hasNext()) {
       	Element field = (Element) elementIter.next();
       	Element version = field.getParentElement();
       	if (version.getAttribute("current").getValue().equals("true")) {
       		LOG.debug("Looking for studentUid field:  " + field.getAttributeValue("name"));
              	if (field.getAttribute("name")!= null && field.getAttributeValue("name").equals("studentUid")) {
              		String employeeId = field.getChildText("value");
           		LOG.debug("Should send an FYI to employee ID:  " + employeeId);
              		if (!StringUtils.isBlank(employeeId)) {
              			Person person = KimApiServiceLocator.getPersonService().getPerson(employeeId);

              			if (person == null) {
              				throw new WorkflowRuntimeException("Failed to locate a Person with the given employee ID: " + employeeId);
              			}
              			if (!context.isSimulation()) {
              				KEWServiceLocator.getWorkflowDocumentService().adHocRouteDocumentToPrincipal(person.getPrincipalId(), context.getDocument(), KewApiConstants.ACTION_REQUEST_FYI_REQ, null, null, "Notification Request", person.getPrincipalId(), "Notification Request", true, null);
              			}
              			//wfDoc.adHocRouteDocumentToPrincipal(KewApiConstants.ACTION_REQUEST_FYI_REQ, "Notification Request", new EmplIdVO(field.getChildText("value")), "Notification Request", true);
               		LOG.debug("Sent FYI using the adHocRouteDocumentToPrincipal function to UniversityID:  " + person.getEmployeeId());
               		break;
              	}
       	}
       }
       }
	return super.process(context, helper);
}
 
Example 6
Source File: RunConfigurationPathMacroFilter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean recursePathMacros(Attribute attribute) {
  final Element parent = attribute.getParent();
  if (parent != null && "option".equals(parent.getName())) {
    final Element grandParent = parent.getParentElement();
    return grandParent != null && "configuration".equals(grandParent.getName());
  }
  return false;
}
 
Example 7
Source File: UpgradeXGAPP.java    From gate-core with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Count the number of ancestor elements of the given element in the
 * tree (i.e. the "depth" of this element in the tree).  The element
 * must be attached to a document for this to be accurate.
 * @param e the element
 * @return the number of ancestor elements, including the root element
 * (but not the document root node, which is not an element).
 */
private static int countAncestors(Element e) {
  int ancestors = 0;
  while((e = e.getParentElement()) != null) {
    ancestors++;
  }
  return ancestors;
}