Search in sources :

Example 1 with SoapApiNamedElement

use of com.zimbra.doc.soap.apidesc.SoapApiNamedElement in project zm-mailbox by Zimbra.

the class CommandChanges method findSubElementChanges.

private void findSubElementChanges(Ancestry ancestry, Map<String, SoapApiNamedElement> baseElems, Map<String, SoapApiNamedElement> currElems) {
    for (Entry<String, SoapApiNamedElement> entry : currElems.entrySet()) {
        SoapApiNamedElement baseElem = baseElems.get(entry.getKey());
        if (baseElem != null) {
            String className = null;
            boolean insideSelf = false;
            if (baseElem instanceof SoapApiElement) {
                SoapApiElement be = (SoapApiElement) baseElem;
                className = be.getJaxb();
                insideSelf = ancestry.hasAncestor(className);
            }
            if (!insideSelf) {
                Ancestry subAncestry = new Ancestry(ancestry, baseElem.getName(), className);
                findElementChanges(subAncestry, baseElem, entry.getValue());
            }
        } else {
            newElems.add(new NamedElem(ancestry.getXpath(), entry.getValue()));
        }
    }
    for (Entry<String, SoapApiNamedElement> entry : baseElems.entrySet()) {
        if (!currElems.containsKey(entry.getKey())) {
            deletedElems.add(new NamedElem(ancestry.getXpath(), entry.getValue()));
        }
    }
}
Also used : SoapApiNamedElement(com.zimbra.doc.soap.apidesc.SoapApiNamedElement) SoapApiElement(com.zimbra.doc.soap.apidesc.SoapApiElement)

Example 2 with SoapApiNamedElement

use of com.zimbra.doc.soap.apidesc.SoapApiNamedElement in project zm-mailbox by Zimbra.

the class CommandChanges method elementChangesBothNonWrapper.

private void elementChangesBothNonWrapper(Ancestry ancestry, SoapApiSimpleElement baseElem, SoapApiSimpleElement currElem) {
    String baseJaxbClass = baseElem.getJaxb();
    SoapApiType baseType = baselineTypes.get(baseJaxbClass);
    SoapApiSimpleElement simpleCurr = (SoapApiSimpleElement) currElem;
    String currJaxbClass = simpleCurr.getJaxb();
    if (currJaxbClass == null) {
        // "curr" doesn't have attributes or sub-elements
        if (baseType != null) {
            if (baseType.getAttributes() != null) {
                for (SoapApiAttribute attr : baseType.getAttributes()) {
                    deletedAttrs.add(new NamedAttr(ancestry.getXpath(), attr));
                }
            }
            Map<String, SoapApiNamedElement> baseSubElems = makeSubElemMap(baseType.getSubElements());
            for (SoapApiNamedElement baseSubElem : baseSubElems.values()) {
                deletedElems.add(new NamedElem(ancestry.getXpath(), baseSubElem));
            }
        }
    } else {
        SoapApiType currType = currentTypes.get(currJaxbClass);
        if (baseType != null) {
            findChanges(ancestry, baseType, currType);
        } else if (currType != null) {
            if (currType.getAttributes() != null) {
                for (SoapApiAttribute attr : currType.getAttributes()) {
                    newAttrs.add(new NamedAttr(ancestry.getXpath(), attr));
                }
            }
            Map<String, SoapApiNamedElement> currSubElems = makeSubElemMap(currType.getSubElements());
            for (SoapApiNamedElement currSubElem : currSubElems.values()) {
                newElems.add(new NamedElem(ancestry.getXpath(), currSubElem));
            }
        }
    }
}
Also used : SoapApiSimpleElement(com.zimbra.doc.soap.apidesc.SoapApiSimpleElement) SoapApiAttribute(com.zimbra.doc.soap.apidesc.SoapApiAttribute) SoapApiNamedElement(com.zimbra.doc.soap.apidesc.SoapApiNamedElement) SoapApiType(com.zimbra.doc.soap.apidesc.SoapApiType) Map(java.util.Map)

Example 3 with SoapApiNamedElement

use of com.zimbra.doc.soap.apidesc.SoapApiNamedElement in project zm-mailbox by Zimbra.

the class CommandChanges method elementChangesWhereBaseIsWrapper.

private void elementChangesWhereBaseIsWrapper(Ancestry ancestry, SoapApiWrapperElement baseWrapper, SoapApiNamedElement currElem) {
    Map<String, SoapApiNamedElement> baseSubElems = makeSubElemMap(baseWrapper.getSubElements());
    if (currElem instanceof SoapApiWrapperElement) {
        // Both "base" and "curr" are wrappers.
        SoapApiWrapperElement currWrapper = (SoapApiWrapperElement) currElem;
        Map<String, SoapApiNamedElement> currSubElems = makeSubElemMap(currWrapper.getSubElements());
        findSubElementChanges(ancestry, baseSubElems, currSubElems);
    } else if (currElem instanceof SoapApiSimpleElement) {
        // "base" was a wrapper.
        SoapApiSimpleElement simpleCurr = (SoapApiSimpleElement) currElem;
        String currJaxbClass = simpleCurr.getJaxb();
        if (currJaxbClass == null) {
            // New class doesn't have children, so, have deleted elements which used to come under wrapper
            for (Entry<String, SoapApiNamedElement> entry : baseSubElems.entrySet()) {
                deletedElems.add(new NamedElem(ancestry.getXpath(), entry.getValue()));
            }
        } else {
            SoapApiType currType = currentTypes.get(currJaxbClass);
            // "base" is a wrapper, so any attributes in "curr" are new
            if (currType.getAttributes() != null) {
                for (SoapApiAttribute attr : currType.getAttributes()) {
                    newAttrs.add(new NamedAttr(ancestry.getXpath(), attr));
                }
            }
            Map<String, SoapApiNamedElement> currSubElems = makeSubElemMap(currType.getSubElements());
            findSubElementChanges(ancestry, baseSubElems, currSubElems);
        }
    }
}
Also used : SoapApiSimpleElement(com.zimbra.doc.soap.apidesc.SoapApiSimpleElement) SoapApiAttribute(com.zimbra.doc.soap.apidesc.SoapApiAttribute) Entry(java.util.Map.Entry) SoapApiNamedElement(com.zimbra.doc.soap.apidesc.SoapApiNamedElement) SoapApiWrapperElement(com.zimbra.doc.soap.apidesc.SoapApiWrapperElement) SoapApiType(com.zimbra.doc.soap.apidesc.SoapApiType) Map(java.util.Map)

Example 4 with SoapApiNamedElement

use of com.zimbra.doc.soap.apidesc.SoapApiNamedElement in project zm-mailbox by Zimbra.

the class CommandChanges method makeSubElemMap.

/**
     * Convenience method.  Creating the map is slightly complicated by SoapApiElementChoiceInfo pseudo nodes
     * which we can ignore for the purposes of the changelog, but we need to promote their children
     */
private Map<String, SoapApiNamedElement> makeSubElemMap(Collection<SoapApiElementArtifact> subElems) {
    Map<String, SoapApiNamedElement> elems = Maps.newTreeMap();
    if (subElems != null) {
        for (SoapApiElementArtifact elemArtifact : subElems) {
            if (elemArtifact instanceof SoapApiElementChoiceInfo) {
                SoapApiElementChoiceInfo choiceNode = (SoapApiElementChoiceInfo) elemArtifact;
                for (SoapApiElementArtifact subE : choiceNode.getSubElements()) {
                    if (subE instanceof SoapApiNamedElement) {
                        SoapApiNamedElement namedE = (SoapApiNamedElement) subE;
                        elems.put(namedE.getName(), namedE);
                    }
                }
            } else if (elemArtifact instanceof SoapApiNamedElement) {
                SoapApiNamedElement namedE = (SoapApiNamedElement) elemArtifact;
                elems.put(namedE.getName(), namedE);
            }
        }
    }
    return elems;
}
Also used : SoapApiElementArtifact(com.zimbra.doc.soap.apidesc.SoapApiElementArtifact) SoapApiNamedElement(com.zimbra.doc.soap.apidesc.SoapApiNamedElement) SoapApiElementChoiceInfo(com.zimbra.doc.soap.apidesc.SoapApiElementChoiceInfo)

Aggregations

SoapApiNamedElement (com.zimbra.doc.soap.apidesc.SoapApiNamedElement)4 SoapApiAttribute (com.zimbra.doc.soap.apidesc.SoapApiAttribute)2 SoapApiSimpleElement (com.zimbra.doc.soap.apidesc.SoapApiSimpleElement)2 SoapApiType (com.zimbra.doc.soap.apidesc.SoapApiType)2 Map (java.util.Map)2 SoapApiElement (com.zimbra.doc.soap.apidesc.SoapApiElement)1 SoapApiElementArtifact (com.zimbra.doc.soap.apidesc.SoapApiElementArtifact)1 SoapApiElementChoiceInfo (com.zimbra.doc.soap.apidesc.SoapApiElementChoiceInfo)1 SoapApiWrapperElement (com.zimbra.doc.soap.apidesc.SoapApiWrapperElement)1 Entry (java.util.Map.Entry)1