Search in sources :

Example 11 with Transient

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

the class RuleSetRuleBean method getActionsAsKeyPair.

@Transient
public HashMap<String, ArrayList<String>> getActionsAsKeyPair(String actionEvaluatesTo) {
    HashMap<String, ArrayList<String>> h = new HashMap<String, ArrayList<String>>();
    for (RuleActionBean action : actions) {
        String key = action.getExpressionEvaluatesTo().toString();
        if (actionEvaluatesTo.equals(key)) {
            if (h.containsKey(key)) {
                h.get(key).add(action.getSummary());
            } else {
                ArrayList<String> a = new ArrayList<String>();
                a.add(action.getSummary());
                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)

Example 12 with Transient

use of javax.persistence.Transient in project eweb4j-framework by laiweiwei.

the class PojoAnnotationConfig method getProperties.

private static List<Property> getProperties(Class<?> clazz, final List<Property> pList, final boolean requireSuper, Log log) throws Throwable {
    List<Property> result = new ArrayList<Property>();
    ReflectUtil ru;
    try {
        ru = new ReflectUtil(clazz);
        ru.setRequiredSuper(requireSuper);
    } catch (Throwable e) {
        log.warn(e.toString(), e);
        throw e;
    }
    for (Field f : ru.getFields()) {
        if (Collection.class.isAssignableFrom(f.getType()))
            continue;
        String name = f.getName();
        Method getter = ru.getGetter(name);
        if (getter == null)
            continue;
        Ignore igAnn = f.getAnnotation(Ignore.class);
        if (igAnn == null)
            igAnn = getter.getAnnotation(Ignore.class);
        if (igAnn != null)
            continue;
        Transient trans = f.getAnnotation(Transient.class);
        if (trans == null)
            trans = getter.getAnnotation(Transient.class);
        if (trans != null)
            continue;
        OneToMany manyAnn = getter.getAnnotation(OneToMany.class);
        if (manyAnn != null)
            continue;
        else {
            manyAnn = f.getAnnotation(OneToMany.class);
            if (manyAnn != null)
                continue;
        }
        ManyToMany manyManyAnn = getter.getAnnotation(ManyToMany.class);
        if (manyManyAnn != null)
            continue;
        else {
            manyManyAnn = f.getAnnotation(ManyToMany.class);
            if (manyManyAnn != null)
                continue;
        }
        Property p = new Property();
        if (Long.class.isAssignableFrom(f.getType()) || long.class.isAssignableFrom(f.getType()))
            p.setSize("20");
        else if (Integer.class.isAssignableFrom(f.getType()) || int.class.isAssignableFrom(f.getType()))
            p.setSize("8");
        else if (String.class.isAssignableFrom(f.getType()))
            p.setSize("255");
        else if (Boolean.class.isAssignableFrom(f.getType()) || boolean.class.isAssignableFrom(f.getType()))
            p.setSize("");
        else if (Float.class.isAssignableFrom(f.getType()) || float.class.isAssignableFrom(f.getType()))
            p.setSize("8");
        Id idAnn = getter.getAnnotation(Id.class);
        if (idAnn == null)
            idAnn = f.getAnnotation(Id.class);
        if (idAnn != null) {
            if (pList != null && hasIdProperty(pList))
                continue;
            p.setAutoIncrement("1");
            p.setPk("1");
            p.setSize("20");
        }
        Column colAnn = getter.getAnnotation(Column.class);
        if (colAnn == null) {
            colAnn = f.getAnnotation(Column.class);
        }
        String column = colAnn == null ? "" : colAnn.name();
        column = "".equals(column.trim()) ? name : column;
        p.setName(name);
        p.setColumn(column);
        p.setType(f.getType().getName());
        p.setNotNull("false");
        if (colAnn != null) {
            // int size = colAnn.length();
            p.setNotNull(String.valueOf(!colAnn.nullable()));
            p.setUnique(String.valueOf(colAnn.unique()));
        }
        if (ClassUtil.isPojo(f.getType())) {
            OneToOne oneAnn = getter.getAnnotation(OneToOne.class);
            if (oneAnn == null)
                oneAnn = f.getAnnotation(OneToOne.class);
            ManyToOne manyToOneAnn = null;
            if (oneAnn == null) {
                manyToOneAnn = getter.getAnnotation(ManyToOne.class);
                if (manyToOneAnn == null)
                    manyToOneAnn = f.getAnnotation(ManyToOne.class);
            }
            if (oneAnn != null || manyToOneAnn != null) {
                if (oneAnn != null)
                    p.setType(PropType.ONE_ONE);
                else
                    p.setType(PropType.MANY_ONE);
                JoinColumn joinColumn = getter.getAnnotation(JoinColumn.class);
                if (joinColumn == null)
                    joinColumn = f.getAnnotation(JoinColumn.class);
                if (joinColumn != null && joinColumn.name().trim().length() > 0)
                    p.setColumn(joinColumn.name());
                else
                    p.setColumn(f.getName() + "_id");
                p.setRelProperty(null);
                String refCol = null;
                if (joinColumn != null && joinColumn.referencedColumnName().trim().length() > 0) {
                    refCol = joinColumn.referencedColumnName();
                    if (refCol != null && refCol.trim().length() > 0) {
                        String relField = ORMConfigBeanUtil.getField(f.getType(), refCol);
                        if (relField != null && relField.trim().length() > 0)
                            p.setRelProperty(relField);
                    }
                }
                p.setRelClass(f.getType());
                p.setSize("20");
            }
        }
        result.add(p);
    }
    return result;
}
Also used : Ignore(org.eweb4j.orm.annotation.Ignore) ArrayList(java.util.ArrayList) ManyToMany(javax.persistence.ManyToMany) Method(java.lang.reflect.Method) OneToMany(javax.persistence.OneToMany) ManyToOne(javax.persistence.ManyToOne) ReflectUtil(org.eweb4j.util.ReflectUtil) Field(java.lang.reflect.Field) OneToOne(javax.persistence.OneToOne) JoinColumn(javax.persistence.JoinColumn) JoinColumn(javax.persistence.JoinColumn) Column(javax.persistence.Column) Transient(javax.persistence.Transient) Id(javax.persistence.Id) Property(org.eweb4j.orm.config.bean.Property)

Example 13 with Transient

use of javax.persistence.Transient in project head by mifos.

the class RESTApprovalEntity method setApprovalMethod.

@Transient
public void setApprovalMethod(ApprovalMethod method) throws Exception {
    approvalMethod = method;
    ObjectMapper om = new ObjectMapper();
    String content = om.writeValueAsString(method);
    setMethodContent(content);
}
Also used : ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Transient(javax.persistence.Transient)

Example 14 with Transient

use of javax.persistence.Transient in project opennms by OpenNMS.

the class BridgeMacLink method printTopology.

@Transient
public String printTopology() {
    final StringBuilder strbfr = new StringBuilder();
    strbfr.append("mac link:[");
    strbfr.append(getMacAddress());
    strbfr.append(", bridge:[");
    strbfr.append(getNode().getId());
    strbfr.append("], bridgeport:");
    strbfr.append(getBridgePort());
    if (getBridgeDot1qTpFdbStatus() != null) {
        strbfr.append(", status:");
        strbfr.append(BridgeDot1qTpFdbStatus.getTypeString(getBridgeDot1qTpFdbStatus().getValue()));
    }
    strbfr.append(", ifindex:");
    strbfr.append(getBridgePortIfIndex());
    strbfr.append("]\n");
    return strbfr.toString();
}
Also used : ToStringBuilder(org.apache.commons.lang.builder.ToStringBuilder) Transient(javax.persistence.Transient)

Example 15 with Transient

use of javax.persistence.Transient in project ORCID-Source by ORCID.

the class ProfileEntity method getCacheKey.

/**
 * Generates a string that will be used for caching proposes
 *
 * @param profile
 * @return a string containing the orcid id and the last modified day,
 *         concatenated by '_'
 */
@Transient
public String getCacheKey() {
    String orcid = this.getId();
    Date lastModified = this.getLastModified() == null ? new Date() : this.getLastModified();
    String lastModifiedString = DateUtils.convertToXMLGregorianCalendar(lastModified).toXMLFormat();
    return StringUtils.join(new String[] { orcid, lastModifiedString }, "_");
}
Also used : Date(java.util.Date) 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