Package siena.core

Examples of siena.core.Owned


 
  private void buildQuery(Field field, Class<?> c) {
    Class<?> type = field.getType();

    Filter filter = field.getAnnotation(Filter.class);
    Owned related = field.getAnnotation(Owned.class);
    if(filter == null && related == null ) {
      throw new SienaException("Found Query<T> field without @Filter or @Owned annotation at "
          +c.getName()+"."+field.getName());
    }

    ParameterizedType pt = (ParameterizedType) field.getGenericType();
    Class<?> cl = (Class<?>) pt.getActualTypeArguments()[0];

    if(filter != null){
      try {
        Map<FieldMapKeys, Object> fieldMap = new HashMap<FieldMapKeys, Object>();
        fieldMap.put(FieldMapKeys.CLASS, cl);
        fieldMap.put(FieldMapKeys.FILTER, filter.value());
        queryFieldMap.put(field, fieldMap);
        ownedFields.add(field);
        hasOwnedFields = true;
      } catch (Exception e) {
        throw new SienaException(e);
      }
    }
    else if(related != null){
      String as = related.mappedBy();
      // if related.as not specified, tries to find the first field with this type
      if("".equals(as) || as == null){
        ClassInfo fieldInfo = ClassInfo.getClassInfo(cl);
        Field f = fieldInfo.getFirstFieldFromType(clazz);
        if(f == null){
View Full Code Here


    ParameterizedType pt = (ParameterizedType) field.getGenericType();
    Class<?> cl = (Class<?>) pt.getActualTypeArguments()[0];
   
    Aggregated agg = field.getAnnotation(Aggregated.class);
    Filter filter = field.getAnnotation(Filter.class);
    Owned related = field.getAnnotation(Owned.class);
    if((agg!=null && filter!=null) || (agg!=null && related!=null)){
      throw new SienaException("Found Many<T> field "
          + c.getName()+"."+field.getName()
          + "with @Filter+@Owned or @Filter+@Owned: this is not authorized");
    }
    if(agg != null){
      try {
        Map<FieldMapKeys, Object> fieldMap = new HashMap<FieldMapKeys, Object>();
        fieldMap.put(FieldMapKeys.CLASS, cl);
        fieldMap.put(FieldMapKeys.MODE, RelationMode.AGGREGATION);
        manyFieldMap.put(field, fieldMap);
        aggregatedFields.add(field);
        hasAggregatedFields = true;
      } catch (Exception e) {
        throw new SienaException(e);
      }
    }else if(filter != null){
      try {
        Field filterField = cl.getField(filter.value());
        if(filterField == null){
          throw new SienaException("@Filter error: Couldn't find field "
              + filter.value()
              + "in class "+cl.getName());
        }
        Map<FieldMapKeys, Object> fieldMap = new HashMap<FieldMapKeys, Object>();
        fieldMap.put(FieldMapKeys.CLASS, cl);
        fieldMap.put(FieldMapKeys.MODE, RelationMode.RELATION);
        fieldMap.put(FieldMapKeys.FIELD, filterField);
        fieldMap.put(FieldMapKeys.FILTER, filter.value());
        manyFieldMap.put(field, fieldMap);
        ownedFields.add(field);
        hasOwnedFields = true;
      } catch (Exception e) {
        throw new SienaException(e);
      }
    }else if(related != null) {
      String as = related.mappedBy();
      // if related.as not specified, tries to find the first field with this type
      if("".equals(as) || as == null){
        ClassInfo fieldInfo = ClassInfo.getClassInfo(cl);
        Field f = fieldInfo.getFirstFieldFromType(clazz);
        if(f == null){
View Full Code Here

    ParameterizedType pt = (ParameterizedType) field.getGenericType();
    Class<?> cl = (Class<?>) pt.getActualTypeArguments()[0];
   
    Aggregated agg = field.getAnnotation(Aggregated.class);
    Filter filter = field.getAnnotation(Filter.class);
    Owned related = field.getAnnotation(Owned.class);
    if((agg!=null && filter!=null) || (agg!=null && related!=null)){
      throw new SienaException("Found One<T> field "
          + c.getName()+"."+field.getName()
          + "with @Filter+@Aggregated or @Filter+@Owned: this is not authorized");
    }
    if(agg != null){
      try {
        Map<FieldMapKeys, Object> fieldMap = new HashMap<FieldMapKeys, Object>();
        fieldMap.put(FieldMapKeys.CLASS, cl);
        fieldMap.put(FieldMapKeys.MODE, RelationMode.AGGREGATION);
        oneFieldMap.put(field, fieldMap);
        aggregatedFields.add(field);
        hasAggregatedFields = true;
    } catch (Exception e) {
        throw new SienaException(e);
      }
    }else if(filter != null){
      try {
        Field filterField = cl.getField(filter.value());
        if(filterField == null){
          throw new SienaException("@Filter error: Couldn't find field "
              + filter.value()
              + "in class "+cl.getName());
        }
        Map<FieldMapKeys, Object> fieldMap = new HashMap<FieldMapKeys, Object>();
        fieldMap.put(FieldMapKeys.CLASS, cl);
        fieldMap.put(FieldMapKeys.MODE, RelationMode.RELATION);
        fieldMap.put(FieldMapKeys.FIELD, filterField);
        fieldMap.put(FieldMapKeys.FILTER, filter.value());
        oneFieldMap.put(field, fieldMap);
        ownedFields.add(field);
        hasOwnedFields = true;
      } catch (Exception e) {
        throw new SienaException(e);
      }
    }else if(related != null) {
      String as = related.mappedBy();
      // if related.as not specified, tries to find the first field with this type
      if("".equals(as) || as == null){
        ClassInfo fieldInfo = ClassInfo.getClassInfo(cl);
        Field f = fieldInfo.getFirstFieldFromType(clazz);
        if(f == null){
View Full Code Here

TOP

Related Classes of siena.core.Owned

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.