Package com.tll.common.model

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


      }

      if(e != null) {
        assert et != null;
        try {
          final Model m = entityToModel(et, e);
          payload.setModel(m);
          payload.getStatus().addMsg(e.descriptor() + " loaded.", MsgLevel.INFO, MsgAttr.STATUS.flag);
        }
        catch(final Exception ex) {
          RpcServlet.exceptionToStatus(ex, payload.getStatus());
View Full Code Here


    context.getMarshaler().marshalModel(modelChanges, e);
    final boolean isNew = e.isNew();
    e = svc.persist(e);

    // marshal
    final Model refreshedModel = marshal(modelChanges.getEntityType(), e);
    payload.setModel(refreshedModel);

    payload.getStatus().addMsg(e.descriptor() + (isNew ? " added." : " updated."), MsgLevel.INFO, MsgAttr.STATUS.flag);
  }
View Full Code Here

    }
    catch(final IllegalArgumentException e) {
      // default fallback
      mo = MarshalOptions.NO_REFERENCES;
    }
    final Model m = context.getMarshaler().marshalEntity(entity, mo);
    assert m != null;
    return m;
  }
View Full Code Here

        fieldPanel.updateModel();
        if(isAdd()) {
          EditEvent.fireAdd(this, fieldPanel.getModel());
        }
        else {
          final Model medited = fieldPanel.getModel();
          final Model mchanged = fieldPanel.getChangedModel();
          EditEvent.fireUpdate(this, medited, mchanged);
        }
      }
      catch(final NoChangesException e) {
        // no field edits were made
View Full Code Here

        }
        else {
          final MarshalOptions mo = getMarshalOptions(context, et, MarshalOptions.NO_REFERENCES);
          final List<Model> elist = new ArrayList<Model>(list.size());
          for(final IEntity e : list) {
            final Model group = context.getMarshaler().marshalEntity(e, mo);
            elist.add(group);
          }
          if(entityMap == null) {
            entityMap = new HashMap<IEntityType, List<Model>>();
          }
          entityMap.put(et, elist);
        }
      }
    }

    // entity prototypes
    etitr = auxDataRequest.getEntityPrototypeRequests();
    while(etitr != null && etitr.hasNext()) {
      final IEntityType et = etitr.next();
      final IEntity e =
        context.getEntityAssembler().assembleEntity(
            (Class<IEntity>) context.getEntityTypeResolver().resolveEntityClass(et), null, false);
      final MarshalOptions mo = getMarshalOptions(context, et, MarshalOptions.NO_REFERENCES);
      final Model model = context.getMarshaler().marshalEntity(e, mo);
      if(entityPrototypes == null) {
        entityPrototypes = new HashSet<Model>();
      }
      entityPrototypes.add(model);
    }
View Full Code Here

    return "Account";
  }

  @Override
  protected Model entityToModel(IEntityType entityType, IEntity e) throws Exception {
    final Model m = super.entityToModel(entityType, e);
    assert m != null;
    final Account a = (Account) e;
    if(a.getParent() != null) {
      final PrimaryKey<Account> pk = new PrimaryKey<Account>(Account.class, a.getParent().getId());
      final IAccountService svc = context.getEntityServiceFactory().instance(IAccountService.class);
      final Account parent = svc.load(pk);
      final Model mparent = new Model(TestEntityType.ACCOUNT);
      mparent.set(new StringPropertyValue(Model.ID_PROPERTY, parent.getId()));
      mparent.set(new StringPropertyValue(Model.NAME_PROPERTY, parent.getName()));
      m.set(new RelatedOneProperty(TestEntityType.ACCOUNT, mparent, "parent", true));
    }
    return m;
  }
View Full Code Here

   * @param name optional name property value. If non-<code>null</code>, a
   *        standard entity name property will be added.
   * @return the stubbed model
   */
  public static Model stubModel(TestEntityType type, Integer version, boolean timestamping, String name) {
    final Model m = new Model(type);
    m.set(new StringPropertyValue(Model.ID_PROPERTY, new PropertyMetadata(PropertyType.STRING, false, true, 10),
        Integer.toString(++nextUniqueId)));
    m.set(new IntPropertyValue(Model.VERSION_PROPERTY, version));
    if(name != null) {
      m.set(new StringPropertyValue(Model.NAME_PROPERTY, new PropertyMetadata(PropertyType.STRING, false, true, 32),
          name));
    }
    m.set(new DatePropertyValue(Model.DATE_CREATED_PROPERTY, new PropertyMetadata(PropertyType.DATE, true, true, 32),
        new Date()));
    m.set(new DatePropertyValue(Model.DATE_MODIFIED_PROPERTY, new PropertyMetadata(PropertyType.DATE, true, true, 32),
        new Date()));
    return m;
  }
View Full Code Here

   * models ("addresses").
   * @param addAddresses Add related many addresses?
   * @return A stubbed root model for testing.
   */
  public static Model stubAccount(boolean addAddresses) {
    final Model account = stubAccount(stubAccount(null, TestEntityType.ACCOUNT, 1), TestEntityType.ACCOUNT, 2);

    final Model aa1 = stubAccountAddress(account, stubAddress(1), 1);
    final Model aa2 = stubAccountAddress(account, stubAddress(2), 2);

    final Set<Model> addresses = addAddresses ? new LinkedHashSet<Model>() : null;
    if(addresses != null) {
      addresses.add(aa1);
      addresses.add(aa2);
View Full Code Here

   * @param accountType
   * @param num
   * @return new instance
   */
  private static Model stubAccount(Model parentAccount, TestEntityType accountType, int num) {
    final Model m = stubModel(accountType, null, true, accountType.descriptor() + " " + num);
    m
    .set(new EnumPropertyValue("status", new PropertyMetadata(PropertyType.ENUM, false, true, 16),
        AccountStatus.OPEN));
    m.set(new BooleanPropertyValue("persistPymntInfo", new PropertyMetadata(PropertyType.BOOL, false, true, -1),
        Boolean.TRUE));
    m.set(new StringPropertyValue("billingModel", new PropertyMetadata(PropertyType.STRING, false, true, 32),
    "a billing model"));
    m.set(new StringPropertyValue("billingCycle", new PropertyMetadata(PropertyType.STRING, false, true, 32),
    "a billing cycle"));
    m
    .set(new DatePropertyValue("dateLastCharged", new PropertyMetadata(PropertyType.DATE, false, true, 32),
        new Date()));
    m
    .set(new DatePropertyValue("nextChargeDate", new PropertyMetadata(PropertyType.DATE, false, true, 32),
        new Date()));
    m.set(new DatePropertyValue("dateCancelled", new PropertyMetadata(PropertyType.DATE, false, true, 32), new Date()));
    m.set(new RelatedOneProperty(TestEntityType.CURRENCY, stubCurrency(), "currency", true));
    m.set(new RelatedOneProperty(TestEntityType.PAYMENT_INFO, stubPaymentInfo(), "paymentInfo", false));
    m.set(new RelatedOneProperty(TestEntityType.ACCOUNT, parentAccount, "parent", true));
    return m;
  }
View Full Code Here

   * @param address
   * @param num
   * @return new instance
   */
  public static Model stubAccountAddress(Model account, Model address, int num) {
    final Model m = stubModel(TestEntityType.ACCOUNT_ADDRESS, null, true, ("Adrs " + num));
    m.set(new EnumPropertyValue("type", new PropertyMetadata(PropertyType.ENUM, false, true, 8),
        AddressType.values()[num - 1]));
    m.set(new RelatedOneProperty(TestEntityType.ACCOUNT, account, "account", true));
    m.set(new RelatedOneProperty(TestEntityType.ADDRESS, address, "address", false));
    return m;
  }
View Full Code Here

TOP

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

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.