Package org.structr.core.property

Examples of org.structr.core.property.PropertyMap


    try {

      List<TestUser> users = createTestNodes(TestUser.class, 1);
      TestUser user = (TestUser) users.get(0);

      PropertyMap props = new PropertyMap();
      props.put(AbstractNode.visibleToPublicUsers, true);

      // Create two nodes with user context, one of them is visible to public users
      Class type = TestOne.class;
      TestOne t1 = createTestNode(TestOne.class, props, user);

      props = new PropertyMap();
      props.put(AbstractNode.visibleToAuthenticatedUsers, true);

      TestOne t2 = createTestNode(TestOne.class, props, user);

      SecurityContext publicContext = SecurityContext.getInstance(null, AccessMode.Frontend);
View Full Code Here


      List<TestUser> users = createTestNodes(TestUser.class, 2);
      TestUser user1 = (TestUser) users.get(0);
      TestUser user2 = (TestUser) users.get(1);

      PropertyMap props = new PropertyMap();
      props.put(AbstractNode.visibleToPublicUsers, true);

      // Create two nodes with user context, one of them is visible to public users
      Class type = TestOne.class;
      TestOne t1 = createTestNode(TestOne.class, props, user1);

      props = new PropertyMap();
      props.put(AbstractNode.visibleToAuthenticatedUsers, true);

      TestOne t2 = createTestNode(TestOne.class, props, user1);

      // Let another user search
      SecurityContext user2Context = SecurityContext.getInstance(user2, AccessMode.Backend);
View Full Code Here

      List<TestUser> users = createTestNodes(TestUser.class, 2);
      TestUser user1 = (TestUser) users.get(0);
      TestUser user2 = (TestUser) users.get(1);

      PropertyMap props = new PropertyMap();
      props.put(AbstractNode.visibleToPublicUsers, true);

      // Create two nodes with user context, one of them is visible to public users
      Class type = TestOne.class;
      TestOne t1 = createTestNode(TestOne.class, props, user1);

      props = new PropertyMap();
      props.put(AbstractNode.visibleToAuthenticatedUsers, true);

      TestOne t2 = createTestNode(TestOne.class, props, user1);

      // Let another user search
      SecurityContext user2Context = SecurityContext.getInstance(user2, AccessMode.Frontend);
View Full Code Here

    }

  }

  protected <T extends AbstractNode> T createTestNode(final Class<T> type, final Principal user) throws FrameworkException {
    return (T)createTestNode(type, new PropertyMap(), user);
  }
View Full Code Here

  }
  public void test02CreateNodeWithExistingUuid() {

    try {

      final PropertyMap props = new PropertyMap();
      TestOne node            = null;

      final String uuid = StringUtils.replace(UUID.randomUUID().toString(), "-", "");

      props.put(GraphObject.id, uuid);

      try (final Tx tx = app.tx()) {

        node = app.create(TestOne.class, props);
        tx.success();
View Full Code Here

   */
  public void test04CheckNodeEntities() {

    AccessControlTest.clearResourceAccess();

    final PropertyMap props = new PropertyMap();

    try (final Tx tx = app.tx()) {

      List<Class> entityList = Collections.EMPTY_LIST;

      try {

        entityList = getClasses("org.structr.core.entity");

      } catch (IOException | ClassNotFoundException ex) {

        logger.log(Level.SEVERE, null, ex);
      }

      assertTrue(entityList.contains(AbstractNode.class));
      assertTrue(entityList.contains(GenericNode.class));
      assertTrue(entityList.contains(Location.class));
      assertTrue(entityList.contains(Person.class));
      assertTrue(entityList.contains(ResourceAccess.class));
      assertTrue(entityList.contains(PropertyAccess.class));

      // Don't test these, it would fail due to violated constraints
      entityList.remove(TestTwo.class);
      entityList.remove(TestNine.class);
      entityList.remove(MailTemplate.class);
      entityList.remove(SchemaNode.class);

      for (Class type : entityList) {

        // for (Entry<String, Class> entity : entities.entrySet()) {
        // Class entityClass = entity.getValue();
        if (AbstractNode.class.isAssignableFrom(type)) {

          // For TestSeven, fill mandatory fields
          if (type.equals(TestSeven.class)) {

            props.put(TestSeven.name, "TestSeven-0");

          }

          // For ResourceAccess, fill mandatory fields
          if (type.equals(ResourceAccess.class)) {

            props.put(ResourceAccess.signature, "/X");
            props.put(ResourceAccess.flags, 6L);

          }

          // For DynamicResourceAccess, fill mandatory fields
          if (type.equals(DynamicResourceAccess.class)) {

            props.put(DynamicResourceAccess.signature, "/Y");
            props.put(DynamicResourceAccess.flags, 6L);

          }

          // For PropertyAccess, fill mandatory fields
          if (type.equals(PropertyAccess.class)) {

            props.put(PropertyAccess.flags, 6L);

          }

          // For Location, set coordinates
          if (type.equals(Location.class)) {

            props.put(Location.latitude, 12.34);
            props.put(Location.longitude, 56.78);

          }

          logger.log(Level.INFO, "Creating node of type {0}", type);

          NodeInterface node = app.create(type, props);

          assertTrue(type.getSimpleName().equals(node.getProperty(AbstractNode.type)));

          // Remove mandatory fields for ResourceAccess from props map
          if (type.equals(ResourceAccess.class)) {

            props.remove(ResourceAccess.signature);
            props.remove(ResourceAccess.flags);

          }

        }
      }
View Full Code Here

   */
  public void test01ModifyNode() {

    try {

      final PropertyMap props = new PropertyMap();
      final String type       = "UnknownTestType";
      final String name       = "GenericNode-name";
     
      NodeInterface node      = null;

      props.put(AbstractNode.type, type);
      props.put(AbstractNode.name, name);

      try (final Tx tx = app.tx()) {
       
        node = app.create(GenericNode.class, props);
        tx.success();
View Full Code Here

        int pageSize        = 2;
        int page            = 1;

        testPaging(type, pageSize, page, number, offset, includeDeletedAndHidden, publicOnly, sortKey, sortDesc);

        PropertyMap props = new PropertyMap();

        props.put(sortKey, "TestOne-09");
        this.createTestNode(type, props);
        testPaging(type, pageSize, page + 1, number + 1, offset - 1, includeDeletedAndHidden, publicOnly, sortKey, sortDesc);
        System.out.println("paging test finished");
      }
View Full Code Here

  //~--- get methods ----------------------------------------------------

  @Override
  public PropertyMap getGroupedProperties(SecurityContext securityContext, GraphObject source) {

    PropertyMap groupedProperties = new PropertyMap();

    for (PropertyKey key : propertyKeys) {

      PropertyConverter converter = key.inputConverter(securityContext);
      if (converter != null) {
       
        try {
          Object convertedValue = converter.revert(source.getProperty(key));
          groupedProperties.put(key, convertedValue);
         
        } catch(FrameworkException fex) {
         
          logger.log(Level.WARNING, "Unable to convert grouped property {0} on type {1}: {2}", new Object[] {
            key.dbName(),
            source.getClass().getSimpleName(),
            fex.getMessage()
           
          });
        }
       
       
      } else {
       
        groupedProperties.put(key, source.getProperty(key));
      }

    }

    return groupedProperties;
View Full Code Here

  public void treeAppendChild(final T childElement) throws FrameworkException {

    final T lastChild = treeGetLastChild();

    PropertyMap properties = new PropertyMap();
    properties.put(AbstractChildren.position, treeGetChildCount());

    // create child relationship
    linkNodes(getChildLinkType(), (T) LinkedTreeNode.this, childElement, properties);

    // add new node to linked list
View Full Code Here

TOP

Related Classes of org.structr.core.property.PropertyMap

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.