Search in sources :

Example 6 with Transient

use of javax.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getRightSiblingOrOfAncestor.

@Transient
MCRCategoryImpl getRightSiblingOrOfAncestor() {
    int index = getPositionInParent();
    MCRCategoryImpl parent = (MCRCategoryImpl) getParent();
    if (index + 1 < parent.getChildren().size()) {
        // has right sibling
        return (MCRCategoryImpl) parent.getChildren().get(index + 1);
    }
    if (parent.getParent() != null) {
        // recursive call to get right sibling of parent
        return parent.getRightSiblingOrOfAncestor();
    }
    // is root
    return parent;
}
Also used : UniqueConstraint(javax.persistence.UniqueConstraint) Transient(javax.persistence.Transient)

Example 7 with Transient

use of javax.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getLeftSiblingOrOfAncestor.

@Transient
MCRCategoryImpl getLeftSiblingOrOfAncestor() {
    int index = getPositionInParent();
    MCRCategoryImpl parent = (MCRCategoryImpl) getParent();
    if (index > 0) {
        // has left sibling
        return (MCRCategoryImpl) parent.getChildren().get(index - 1);
    }
    if (parent.getParent() != null) {
        // recursive call to get left sibling of parent
        return parent.getLeftSiblingOrOfAncestor();
    }
    // is root
    return parent;
}
Also used : UniqueConstraint(javax.persistence.UniqueConstraint) Transient(javax.persistence.Transient)

Example 8 with Transient

use of javax.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getPositionInParentByID.

@Transient
private int getPositionInParentByID() {
    int position = 0;
    for (MCRCategory sibling : parent.getChildren()) {
        if (getId().equals(sibling.getId())) {
            return position;
        }
        position++;
    }
    if (LOGGER.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder("List of children of parent: ");
        sb.append(parent.getId()).append('\n');
        for (MCRCategory sibling : parent.getChildren()) {
            sb.append(sibling.getId()).append('\n');
        }
        LOGGER.debug(sb.toString());
    }
    throw new IndexOutOfBoundsException("Position -1 is not valid: " + getId() + " parent:" + parent.getId() + " children: " + parent.getChildren().stream().map(MCRCategory::getId).map(MCRCategoryID::getID).collect(Collectors.joining(", ")));
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory) UniqueConstraint(javax.persistence.UniqueConstraint) Transient(javax.persistence.Transient)

Example 9 with Transient

use of javax.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getLeftSiblingOrParent.

@Transient
MCRCategoryImpl getLeftSiblingOrParent() {
    int index = getPositionInParent();
    MCRCategoryImpl parent = (MCRCategoryImpl) getParent();
    if (index == 0) {
        return parent;
    }
    return (MCRCategoryImpl) parent.getChildren().get(index - 1);
}
Also used : UniqueConstraint(javax.persistence.UniqueConstraint) Transient(javax.persistence.Transient)

Example 10 with Transient

use of javax.persistence.Transient in project OpenClinica by OpenClinica.

the class RuleSetRuleBean method getAllActionsWithEvaluatesToAsKey.

@Transient
public HashMap<String, ArrayList<RuleActionBean>> getAllActionsWithEvaluatesToAsKey() {
    HashMap<String, ArrayList<RuleActionBean>> h = new HashMap<String, ArrayList<RuleActionBean>>();
    for (RuleActionBean action : actions) {
        String key = action.getExpressionEvaluatesTo().toString();
        if (h.containsKey(key)) {
            h.get(key).add(action);
        } else {
            ArrayList<RuleActionBean> a = new ArrayList<RuleActionBean>();
            a.add(action);
            h.put(key, a);
        }
    }
    return h;
}
Also used : RuleActionBean(org.akaza.openclinica.domain.rule.action.RuleActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Transient(javax.persistence.Transient)

Aggregations

Transient (javax.persistence.Transient)22 ArrayList (java.util.ArrayList)6 UniqueConstraint (javax.persistence.UniqueConstraint)5 HashMap (java.util.HashMap)4 Method (java.lang.reflect.Method)3 RuleActionBean (org.akaza.openclinica.domain.rule.action.RuleActionBean)3 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 ManyToMany (javax.persistence.ManyToMany)2 ManyToOne (javax.persistence.ManyToOne)2 OneToMany (javax.persistence.OneToMany)2 OneToOne (javax.persistence.OneToOne)2 ToStringBuilder (org.apache.commons.lang.builder.ToStringBuilder)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 Annotation (java.lang.annotation.Annotation)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Field (java.lang.reflect.Field)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 List (java.util.List)1 Access (javax.persistence.Access)1