Package com.tll.common.model

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


        public void onEdit(EditEvent event) {
          Integer version;

          // mimic model persist life-cycle
          assert m != null;
          final Model mcopy = m.copy(mcrit);
          version = mcopy.getVersion();
          mcopy.setVersion(version == null ? 0 : version++);
          ArrayList<Model> alist = null;
          List<Model> existing;
          final RelatedManyProperty ap = mcopy.relatedMany("addresses");
          existing = ap.getModelList();
          if(existing != null) {
            alist = new ArrayList<Model>();
            for(final Model am : existing) {
              if(!am.isMarkedDeleted()) {
View Full Code Here


   * @throws Exception
   */
  public void testModelChangeSupportAggregation() throws Exception {

    final Model[] lr = stubLeftAndRight();
    final Model left = lr[0];
    final Model right = lr[1];

    final Binding binding = new Binding();
    final List<Binding> children = binding.getChildren();
    children.add(new Binding(left, right, Model.ID_PROPERTY));
    children.add(new Binding(left, right, Model.NAME_PROPERTY));
View Full Code Here

   * @throws Exception
   */
  public void testPropertyChangeSyncing() throws Exception {

    final Model[] lr = stubLeftAndRight();
    final Model left = lr[0];
    final Model right = lr[1];

    final Binding binding = new Binding();
    final List<Binding> children = binding.getChildren();
    children.add(new Binding(left, right, Model.ID_PROPERTY));
    children.add(new Binding(left, right, Model.NAME_PROPERTY));
    children.add(new Binding(left, right, Model.DATE_CREATED_PROPERTY));
    children.add(new Binding(left, right, Model.DATE_MODIFIED_PROPERTY));
    children.add(new Binding(left, right, "parent.name"));
    children.add(new Binding(left, right, "addresses[0].address.firstName"));

    binding.bind();

    // clear out the bound properties on the right..
    right.clearPropertyValue(Model.ID_PROPERTY);
    right.clearPropertyValue(Model.NAME_PROPERTY);
    right.clearPropertyValue(Model.DATE_CREATED_PROPERTY);
    right.clearPropertyValue(Model.DATE_MODIFIED_PROPERTY);
    right.clearPropertyValue("parent.name");
    right.clearPropertyValue("addresses[0].address.firstName");

    verifyInSync(left, right);

    // set bound properties on the left..
    left.setProperty(Model.ID_PROPERTY, Integer.toString(33));
View Full Code Here

   * @throws Exception
   */
  public void testIndexedPropertyMutation() throws Exception {

    final Model[] lr = stubLeftAndRight();
    final Model left = lr[0];
    final Model right = lr[1];

    // create the binding
    final Binding binding = new Binding();
    binding.getChildren().add(new Binding(left, right, "addresses"));
    binding.bind();

    Object val;

    // remove indexed property on the left
    left.setProperty("addresses[1]", null);

    // verify
    try {
      val = left.getProperty("addresses[1]");
    }
    catch(final IndexOutOfRangeInPropPathException e) {
      // expected
    }
    val = left.getProperty("addresses");
    Assert.assertTrue(val instanceof List<?> && ((List<?>) val).size() == 1);

    val = right.getProperty("addresses");
    Assert.assertTrue(val instanceof List<?> && ((List<?>) val).size() == 1);

    // add an indexed property on the right
    final Model aa = TestModelStubber.stubAccountAddress(right, TestModelStubber.stubAddress(2), 2);
    right.setProperty("addresses[1]", aa);

    // verify
    val = right.getProperty("addresses");
    Assert.assertTrue(val instanceof List<?> && ((List<?>) val).size() == 2);
View Full Code Here

   * Stubs distinct left and right {@link Model} instances
   * @return 2 element array where the first element is the left model
   * @throws Exception
   */
  protected Model[] stubLeftAndRight() throws Exception {
    final Model left = TestModelStubber.stubAccount(true);
    final Model right = left.copy(CopyCriteria.all());
    // right.setAsRoot();

    // sanity check: verify we are equal before we bind
    ModelTestUtils.validateCopy(left, right, CopyCriteria.all());

View Full Code Here

      return aaName + " (" + type.getName() + ")";
    }

    @Override
    protected Model createPrototypeModel() {
      final Model m = TestModelStubber.stubAccountAddress(null, TestModelStubber.stubAddress(1), 1);
      m.clearPropertyValues(false, true);
      return m;
    }
View Full Code Here

      catch(final PropertyPathException e) {
        throw new IllegalStateException(e);
      }
      if(mp != null) whitelist.add(mp);
    }
    final Model subset = model.copy(CopyCriteria.subset(whitelist));
    return subset;
  }
View Full Code Here

    final PrimaryKeySearch search = new PrimaryKeySearch(new ModelKey(TestEntityType.ADDRESS, id, null));
    final LoadRequest<PrimaryKeySearch> request = new LoadRequest<PrimaryKeySearch>(search);
    final ModelPayload p = delegate.load(request);

    assert p != null;
    final Model m = p.getModel();
    assert m != null;
    assert m.getId() != null && m.getId().equals(id) && m.getEntityType() != null
    && m.getEntityType().equals(TestEntityType.ADDRESS);
  }
View Full Code Here

   */
  @Test
  public void testAdd() throws Exception {
    final PersistServiceDelegate delegate = getDelegate();

    Model m = new Model(TestEntityType.ADDRESS);
    m.set(new StringPropertyValue(Model.ID_PROPERTY, "10000"));
    m.set(new StringPropertyValue("address1", "1 tee streetU"));
    m.set(new StringPropertyValue("address2", "2 bee"));
    m.set(new StringPropertyValue("city", "the city"));
    m.set(new StringPropertyValue("country", "us"));
    m.set(new StringPropertyValue("emailAddress", "email@schmemail.com"));
    m.set(new StringPropertyValue("fax", "2223334444"));
    m.set(new StringPropertyValue("firstName", "First"));
    m.set(new StringPropertyValue("lastName", "Last"));
    m.set(new CharacterPropertyValue("mi", 'm'));
    m.set(new StringPropertyValue("phone", "1112223333"));
    m.set(new StringPropertyValue("postalCode", "48104"));
    m.set(new StringPropertyValue("province", "MI"));

    final ModelPayload p = delegate.persist(new PersistRequest(m, false));
    assert p != null;
    m = p.getModel();
    assert m != null;
    assert m.getId() != null && m.getId().equals("10000") && m.getEntityType() != null
    && m.getEntityType().equals(TestEntityType.ADDRESS);
    final Object ov = m.getProperty("version");
    assert ov != null && ov.equals(0);
  }
View Full Code Here

    final String id = a.getId();
    addEntityToDb(a);

    final PersistServiceDelegate delegate = getDelegate();

    Model m = new Model(TestEntityType.ADDRESS);
    m.set(new IntPropertyValue(Model.VERSION_PROPERTY, 0));
    m.set(new StringPropertyValue(Model.ID_PROPERTY, id));
    m.set(new StringPropertyValue("address1", "1 changed street"));
    m.set(new StringPropertyValue("address2", "2 beechange"));
    m.set(new StringPropertyValue("city", "change city"));

    final ModelPayload p = delegate.persist(new PersistRequest(m, true));
    assert p != null;
    m = p.getModel();
    assert m != null;
    assert m.getId() != null && m.getId().equals(id) && m.getEntityType() != null
    && m.getEntityType().equals(TestEntityType.ADDRESS);
    final Object ov = m.getProperty("version");
    assert ov != null && ov.equals(1);
  }
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.