示例#1
0
 private String getVolumeTag(ToolVolume volume) {
   if (volume != null) {
     final AutoBean<ToolVolume> volumeAutoBean = AutoBeanUtils.getAutoBean(volume);
     String currentTag = volumeAutoBean.getTag(TOOL_VOLUME_MODEL_KEY);
     if (currentTag == null) {
       volumeAutoBean.setTag(TOOL_VOLUME_MODEL_KEY, String.valueOf(unique_volume_id++));
     }
     return volumeAutoBean.getTag(TOOL_VOLUME_MODEL_KEY);
   }
   return "";
 }
 /**
  * Convert a client-side value into a domain value.
  *
  * @param maybeEntityProxy the client object to resolve
  * @param detectDeadEntities if <code>true</code> this method will throw a ReportableException
  *     containing a {@link DeadEntityException} if an EntityProxy cannot be resolved
  */
 public Object resolveDomainValue(Object maybeEntityProxy, boolean detectDeadEntities) {
   if (maybeEntityProxy instanceof BaseProxy) {
     AutoBean<BaseProxy> bean = AutoBeanUtils.getAutoBean((BaseProxy) maybeEntityProxy);
     Object domain = bean.getTag(Constants.DOMAIN_OBJECT);
     if (domain == null && detectDeadEntities) {
       throw new ReportableException(
           new DeadEntityException("The requested entity is not available on the server"));
     }
     return domain;
   } else if (maybeEntityProxy instanceof Collection<?>) {
     Collection<Object> accumulator;
     if (maybeEntityProxy instanceof List<?>) {
       accumulator = new ArrayList<Object>();
     } else if (maybeEntityProxy instanceof Set<?>) {
       accumulator = new HashSet<Object>();
     } else {
       throw new ReportableException(
           "Unsupported collection type " + maybeEntityProxy.getClass().getName());
     }
     for (Object o : (Collection<?>) maybeEntityProxy) {
       accumulator.add(resolveDomainValue(o, detectDeadEntities));
     }
     return accumulator;
   }
   return maybeEntityProxy;
 }