Package com.tll.common.model

Examples of com.tll.common.model.Model$SubsetPredicate


        @Override
        public void render(FlowPanel widget, FieldGroup fg) {
          final FlowPanelFieldComposer cmpsr = new FlowPanelFieldComposer();
          cmpsr.setCanvas(widget);

          final Model m = getModel();
          assert m != null;

          cmpsr.addField(fg.getFieldWidget("subscribed"));
          cmpsr.newRow();

          lblDesc.setText(m.asString("description"));
          cmpsr.addWidget("Description", lblDesc);
          cmpsr.newRow();

          try {
            lblDflt.setText(Fmt.format(m.getPropertyValue("default").getValue(), GlobalFormat.BOOL_YESNO));
          }
          catch(final Exception e) {
            throw new IllegalArgumentException(e);
          }
          cmpsr.addWidget("Default?", lblDflt);
          cmpsr.newRow();

          if(m.relatedMany("parameters").size() > 0) {
            cmpsr.newRow();
            cmpsr.addWidget(paramsPanel);
          }

          cmpsr.newRow();
View Full Code Here


      @Override
      public void render(FlowPanel widget, FieldGroup fg) {
        final FlowPanelFieldComposer cmpsr = new FlowPanelFieldComposer();
        cmpsr.setCanvas(widget);

        final Model m = getModel();
        assert m != null;

        cmpsr.newRow();
        cmpsr.addField(fg.getFieldWidget("subscribed"));
        cmpsr.addField(fg.getFieldWidget("setUpPrice"));
        cmpsr.addField(fg.getFieldWidget("monthlyPrice"));
        cmpsr.addField(fg.getFieldWidget("annualPrice"));

        if(m.relatedMany("options[0].parameters").size() > 0) {
          cmpsr.newRow();
          cmpsr.addWidget(paramsPanel);
        }
      }
    };
View Full Code Here

      cmpsr.resetFlow();
      cmpsr.addField(fg.getFieldWidget("user" + Model.NAME_PROPERTY));
      cmpsr.addField(fg.getFieldWidget("userExpires"));

      // parent account ref link
      final Model parentAccount = getModel().nestedModel("account");
      final String paName = parentAccount.asString(Model.NAME_PROPERTY);
      lnkAccount.setViewNames(paName, paName);
      lnkAccount.setViewInitializer(new EditViewInitializer(AccountEditView.klas, parentAccount));
      cmpsr.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
      cmpsr.addWidget("Account", lnkAccount);
View Full Code Here

   *         resolved from the given SearchResult.
   */
  public Model marshalSearchResult(final SearchResult<?> searchResult, final MarshalOptions options) {
    assert searchResult != null;
    assert options != null;
    Model model;
    final Object r = searchResult.getElement();
    if(r instanceof IEntity) {
      BindingRefSet<IEntity, Model> visited = new BindingRefSet<IEntity, Model>();
      model = marshalEntity((IEntity) r, options, visited, 0);
      visited = null;
View Full Code Here

   * @return Marshaled object as a {@link Model}.
   * @throws RuntimeException upon any error encountered.
   */
  public <S extends IScalar> Model marshalScalar(final S source, final MarshalOptions options) {

    final Model model = new Model(etResolver.resolveEntityType(source.getRefType()));

    final Map<String, Object> tupleMap = source.getTupleMap();
    for(final Map.Entry<String, Object> e : tupleMap.entrySet()) {
      final String pname = e.getKey();
      final Object obj = e.getValue();
      // NOTE: if we have a null tuple value, then default the type to String!
      final Class<?> ptype = obj == null ? String.class : obj.getClass();
      final IModelProperty prop = createValueProperty(ptype, pname, obj, null);
      if(prop != null) {
        model.set(prop);
      }
    }

    return model;
  }
View Full Code Here

    // check visited
    final Binding<IEntity, Model> b = visited.findBindingBySource(source);
    if(b != null) return b.tgt;

    final Class<? extends IEntity> entityClass = source.entityClass();
    final Model model = new Model(etResolver.resolveEntityType(entityClass));

    visited.add(new Binding<IEntity, Model>(source, model));

    final BeanWrapperImpl bw = new BeanWrapperImpl(source);

    for(final PropertyDescriptor pd : bw.getPropertyDescriptors()) {
      final String pname = pd.getName();

      // skip certain properties...
      if(!bw.isWritableProperty(pname) || !isMarshalableProperty(pd)) {
        continue;
      }

      final Class<?> ptype = pd.getPropertyType();
      Object obj = null;
      try {
        obj = bw.getPropertyValue(pname);
      }
      catch(final RuntimeException re) {
        log.debug("Skipping entity prop: " + pname + " due to: " + re.getMessage());
        continue;
      }

      final PropertyMetadata pdata = generatePropertyData(entityClass, pname);

      IModelProperty prop = createValueProperty(ptype, pname, obj, pdata);

      if(prop == null) {
        // related one
        if(IEntity.class.isAssignableFrom(ptype)) {
          final RelationInfo ri = schemaInfo.getRelationInfo(entityClass, pname);
          final boolean reference = ri.isReference();
          if(shouldMarshalRelation(reference, depth, options)) {
            final IEntity e = (IEntity) obj;
            final Model m = e == null ? null : marshalEntity(e, options, visited, depth + 1);
            final IEntityType etype =
              ri.getRelatedType() == null ? null : etResolver.resolveEntityType(e == null ? ri.getRelatedType() : e
                  .entityClass());
            prop = new RelatedOneProperty(etype, m, pname, reference);
          }
        }

        // related many collection
        else if(Collection.class.isAssignableFrom(ptype)) {
          final RelationInfo ri = schemaInfo.getRelationInfo(entityClass, pname);
          final boolean reference = ri.isReference();
          if(shouldMarshalRelation(reference, depth, options)) {
            List<Model> list = null;
            if(obj != null) {
              list = new ArrayList<Model>();
              final Collection<IEntity> set = (Collection<IEntity>) obj;
              for(final IEntity e : set) {
                final Model nested = marshalEntity(e, options, visited, depth + 1);
                list.add(nested);
              }
            }
            prop = new RelatedManyProperty(etResolver.resolveEntityType(ri.getRelatedType()), pname, reference, list);
          }
View Full Code Here

      case FLOAT:
        val = ((Double) pval).floatValue();
        break;

      case RELATED_ONE: {
        final Model rltdOne = (Model) pval;
        final IEntityType rltdEntityType =
          rltdOne == null ? ((RelatedOneProperty) mprop).getRelatedType() : rltdOne.getEntityType();
          assert rltdEntityType != null;
          IEntity toOne;
          if(rltdOne == null || rltdOne.isMarkedDeleted()) {
            toOne = null;
          }
          else {
            final Class<? extends IEntity> rltdEntityClass =
              (Class<? extends IEntity>) etResolver.resolveEntityClass(rltdEntityType);
View Full Code Here

    final Iterator<Account> aitr = accounts.iterator();
    final Account account = aitr.next(), parent = aitr.next();
    account.setParent(parent);
    parent.setParent(account);

    final Model model = marshaler.marshalEntity(account, MarshalOptions.UNCONSTRAINED_MARSHALING);
    Assert.assertTrue(model != null);
    final Account unmarshaled = marshaler.marshalModel(model, Account.class);
    Assert.assertTrue(unmarshaled != null);
    Assert.assertEquals(account, unmarshaled);
  }
View Full Code Here

    final Marshaler marshaler = getMarshaler();
    Assert.assertTrue(marshaler != null);
    final IEntity e = getEntityBeanFactory().getEntityCopy(NestedEntity.class, false);
    Assert.assertNotNull(e);

    final Model model = marshaler.marshalEntity(e, MarshalOptions.UNCONSTRAINED_MARSHALING);
    Assert.assertNotNull(model);
    final IEntity e2 = marshaler.marshalModel(model, e.entityClass());
    Assert.assertNotNull(e2);
    Assert.assertEquals(e, e2);
  }
View Full Code Here

      }
    };

    final Marshaler marshaler = getMarshaler();
    Assert.assertTrue(marshaler != null);
    final Model model = marshaler.marshalScalar(scalar, MarshalOptions.UNCONSTRAINED_MARSHALING);

    final Iterator<IModelProperty> itr = model.iterator();
    while(itr.hasNext()) {
      final IModelProperty prop = itr.next();
      Assert.assertTrue(prop != null);
      final Object val = tupleMap.get(prop.getPropertyName());
      Assert.assertTrue(val != null);
View Full Code Here

TOP

Related Classes of com.tll.common.model.Model$SubsetPredicate

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.