Пример #1
0
  /** This method should be called when after okButton is clicked. */
  ArgumentValidator getArgumentValidator() {
    Splittable params = StringQuoter.createIndexed();

    switch (validatorTypeCB.getCurrentValue()) {
      case Regex:
        String regex = regexField.getCurrentValue();
        StringQuoter.create(regex).assign(params, 0);
        break;
      case CharacterLimit:
        int charLimit = charLimitField.getCurrentValue();
        StringQuoter.create(charLimit).assign(params, 0);
        break;

      case IntAbove:
        int intAbove = intAboveField.getCurrentValue();
        StringQuoter.create(intAbove).assign(params, 0);
        break;

      case IntBelow:
        int intBelow = intBelowField.getCurrentValue();
        StringQuoter.create(intBelow).assign(params, 0);
        break;
      case IntRange:
        int intRangeAbove = intRangeAboveField.getCurrentValue();
        int intRangeBelow = intRangeBelowField.getCurrentValue();
        StringQuoter.create(intRangeAbove).assign(params, 0);
        StringQuoter.create(intRangeBelow).assign(params, 1);
        break;

      case DoubleAbove:
        double dblAbove = dblAboveField.getCurrentValue();
        StringQuoter.create(dblAbove).assign(params, 0);
        break;
      case DoubleBelow:
        double dblBelow = dblBelowField.getCurrentValue();
        StringQuoter.create(dblBelow).assign(params, 0);
        break;

      case DoubleRange:
        double dblRangeAbove = dblRangeAboveField.getCurrentValue();
        double dblRangeBelow = dblRangeBelowField.getCurrentValue();
        StringQuoter.create(dblRangeAbove).assign(params, 0);
        StringQuoter.create(dblRangeBelow).assign(params, 1);
        break;
      default:
        break;
    }
    AutoBean<ArgumentValidator> avAutobean = factory.argumentValidator();
    avAutobean.as().setType(validatorTypeCB.getCurrentValue());
    avAutobean.as().setParams(params);

    // JDS Get the actual validator, and add it as metadata to the autobean.
    AbstractArgumentEditor.createAndAttachValidator(avAutobean.as());

    return avAutobean.as();
  }
  @Override
  public ReferenceGenome convertModelValue(Splittable object) {
    if (object == null) {
      return null;
    }
    if (!object.isKeyed()) {
      return null;
    }

    AutoBean<ReferenceGenome> ab = AutoBeanCodex.decode(factory, ReferenceGenome.class, object);
    return ab.as();
  }
  /** Creates a proxy instance held by a Resolution for a given domain type. */
  private <T extends BaseProxy> Resolution resolveClientProxy(
      Object domainEntity, Class<T> proxyType, ResolutionKey key) {
    if (domainEntity == null) {
      return null;
    }

    SimpleProxyId<? extends BaseProxy> id = state.getStableId(domainEntity);

    boolean isEntityProxy = state.isEntityType(proxyType);
    Object domainVersion;

    // Create the id or update an ephemeral id by calculating its address
    if (id == null || id.isEphemeral()) {
      // The address is an id or an id plus a path
      Object domainId;
      if (isEntityProxy) {
        // Compute data needed to return id to the client
        domainId = service.getId(domainEntity);
        domainVersion = service.getVersion(domainEntity);
      } else {
        domainId = null;
        domainVersion = null;
      }
      if (id == null) {
        if (domainId == null) {
          /*
           * This will happen when server code attempts to return an unpersisted
           * object to the client. In this case, we'll assign a synthetic id
           * that is valid for the duration of the response. The client is
           * expected to assign a client-local id to this object and then it
           * will behave as though it were an object newly-created by the
           * client.
           */
          id = state.getIdFactory().allocateSyntheticId(proxyType, ++syntheticId);
        } else {
          Splittable flatValue = state.flatten(domainId);
          id = state.getIdFactory().getId(proxyType, flatValue.getPayload(), 0);
        }
      } else if (domainId != null) {
        // Mark an ephemeral id as having been persisted
        Splittable flatValue = state.flatten(domainId);
        id.setServerId(flatValue.getPayload());
      }
    } else if (isEntityProxy) {
      // Already have the id, just pull the current version
      domainVersion = service.getVersion(domainEntity);
    } else {
      // The version of a value object is always null
      domainVersion = null;
    }

    @SuppressWarnings("unchecked")
    AutoBean<T> bean = (AutoBean<T>) state.getBeanForPayload(id, domainEntity);
    bean.setTag(Constants.IN_RESPONSE, true);
    if (domainVersion != null) {
      Splittable flatVersion = state.flatten(domainVersion);
      bean.setTag(
          Constants.VERSION_PROPERTY_B64,
          SimpleRequestProcessor.toBase64(flatVersion.getPayload()));
    }

    T clientObject = bean.as();
    return makeResolution(key, clientObject);
  }
 public <T> T decode(Class<T> clazz, String json) {
   AutoBean<T> bean = AutoBeanCodex.decode(messageFactory, clazz, json);
   return bean.as();
 }
Пример #5
0
 private IResponse decodeJSON(String json) {
   IResponseFactory factory = GWT.create(IResponseFactory.class);
   AutoBean<IResponse> bean = AutoBeanCodex.decode(factory, IResponse.class, json);
   return bean.as();
 }