Package org.structr.core.property

Examples of org.structr.core.property.PropertyMap


  @Override
  public T deserialize(SecurityContext securityContext, Class<T> type, S source) throws FrameworkException {

    if (source instanceof JsonInput) {
     
      PropertyMap attributes = PropertyMap.inputTypeToJavaType(securityContext, type, ((JsonInput)source).getAttributes());
      return deserialize(securityContext, type, attributes);
    }
   
    if (source instanceof Map) {
     
      PropertyMap attributes = PropertyMap.inputTypeToJavaType(securityContext, type, (Map)source);
      return deserialize(securityContext, type, attributes);
    }
   
    return null;
  }
View Full Code Here


    // create and fill input map with source object
    Map<String, Object> sourceMap = new LinkedHashMap<>();
    sourceMap.put(propertyKey.jsonName(), source);

    // try to convert input type to java type in order to create object correctly
    PropertyMap convertedSourceMap = PropertyMap.inputTypeToJavaType(securityContext, type, sourceMap);
    Object convertedSource = convertedSourceMap.get(propertyKey);
   
    if (convertedSource != null) {

      // FIXME: use uuid only here?
      if (convertedSource instanceof JsonInput) {
View Full Code Here

  @Override
  public Object serialize(SecurityContext securityContext, Class type, GraphObject source) throws FrameworkException {

    if (source != null) {
     
      PropertyMap propertyMap = new PropertyMap();
      for (PropertyKey key : propertyKeys) {
        propertyMap.put(key, source.getProperty(key));
      }
     
      return PropertyMap.javaTypeToInputType(securityContext, type, propertyMap);
    }
View Full Code Here

    final Map<String, PropertyMap> notionPropertyMap = (Map<String, PropertyMap>)securityContext.getAttribute("notionProperties");
    if (notionPropertyMap != null) {

      final Set<PropertyKey> keySet      = Services.getInstance().getConfigurationProvider().getPropertySet(type, PropertyView.Public);
      final PropertyMap notionProperties = notionPropertyMap.get(entityKey);

      for (final Iterator<PropertyKey> it = notionProperties.keySet().iterator(); it.hasNext();) {

        final PropertyKey key = it.next();
        if (!keySet.contains(key)) {

          it.remove();
View Full Code Here

   *
   * @throws FrameworkException
   */
  public static Location createLocation(final GeoCodingResult coords) throws FrameworkException {

    final PropertyMap props = new PropertyMap();
    double latitude         = coords.getLatitude();
    double longitude        = coords.getLongitude();
    String type             = Location.class.getSimpleName();

    props.put(AbstractNode.type,  type);
    props.put(Location.latitude,  latitude);
    props.put(Location.longitude, longitude);

    return StructrApp.getInstance().create(Location.class, props);
  }
View Full Code Here

  @Override
  public <T extends NodeInterface> T create(final Class<T> type, final PropertyMap source) throws FrameworkException {

    final CreateNodeCommand<T> command = command(CreateNodeCommand.class);
    final PropertyMap properties       = new PropertyMap(source);

    // add type information when creating a node
    properties.put(AbstractNode.type, type.getSimpleName());

    return command.execute(properties);
  }
View Full Code Here

  @Override
  public T deserialize(SecurityContext securityContext, Class<T> type, S source) throws FrameworkException {

    if (source instanceof JsonInput) {
     
      PropertyMap attributes = PropertyMap.inputTypeToJavaType(securityContext, type, ((JsonInput)source).getAttributes());
      return deserialize(securityContext, type, attributes);
    }
   
    if (source instanceof Map) {
     
      PropertyMap attributes = PropertyMap.inputTypeToJavaType(securityContext, type, (Map)source);
      return deserialize(securityContext, type, attributes);
    }
   
    return null;
  }
View Full Code Here

        case 0:

          if (createIfNotExisting) {

            // remove attributes that do not belong to the target node
            final PropertyMap foreignProperties = new PropertyMap();

            for (final Iterator<PropertyKey> it = attributes.keySet().iterator(); it.hasNext();) {

              final PropertyKey key = it.next();
              if (foreignPropertyKeys.contains(key)) {

                // move entry to foreign map and remove from attributes
                foreignProperties.put(key, attributes.get(key));
                it.remove();
              }
            }
           
            // create node and return it
View Full Code Here

        final String type = typeInfo.getPrimaryType();
        if (!"ReferenceNode".equals(type)) {

          final Map<String, Class> props = typeInfo.getPropertySet();
          final PropertyMap propertyMap  = new PropertyMap();

          // add properties
          for (final Map.Entry<String, Class> propertyEntry : props.entrySet()) {

            final String propertyName = propertyEntry.getKey();
            final Class propertyType  = propertyEntry.getValue();

            // handle array types differently
            String propertyTypeName = propertyType.getSimpleName();
            if (propertyType.isArray()) {

              // remove "[]" from the end and append "Array" to match the appropriate parser
              propertyTypeName = propertyTypeName.substring(0, propertyTypeName.length() - 2).concat("Array");
            }

            propertyMap.put(new StringProperty("_".concat(propertyName)), propertyTypeName);
          }

          // set node type which is in "name" property
          propertyMap.put(AbstractNode.name, type);

          // check if there is an existing Structr entity with the same type
          // and make the dynamic class extend the existing class if yes.
          final Class existingType = configuration.getNodeEntityClass(type);
          if (existingType != null) {

            propertyMap.put(SchemaNode.extendsClass, existingType.getName());

          } else if (!typeInfo.getOtherTypes().isEmpty()) {

            // only the first supertype is supported
            propertyMap.put(SchemaNode.extendsClass, typeInfo.getSuperclass(reducedTypeInfoMap));
          }

          // create schema node
          schemaNodes.put(type, app.create(SchemaNode.class, propertyMap));
        }
      }

      // create relationships
      for (final RelationshipInfo template : reducedRelationshipInfos) {

        final SchemaNode startNode    = schemaNodes.get(template.getStartNodeType());
        final SchemaNode endNode      = schemaNodes.get(template.getEndNodeType());
        final String relationshipType = template.getRelType();
        final PropertyMap propertyMap = new PropertyMap();

        propertyMap.put(SchemaRelationship.sourceId, startNode.getUuid());
        propertyMap.put(SchemaRelationship.targetId, endNode.getUuid());
        propertyMap.put(SchemaRelationship.relationshipType, relationshipType);

        app.create(startNode, endNode, SchemaRelationship.class, propertyMap);
      }

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.