Package org.structr.core.converter

Examples of org.structr.core.converter.PropertyConverter


              if (propertyKey != null) {

                try {
                  Object convertedValue = val;

                  PropertyConverter inputConverter = propertyKey.inputConverter(SecurityContext.getSuperUserInstance());
                  if (inputConverter != null) {

                    convertedValue = inputConverter.convert(val);
                  }

                  //newNode.unlockReadOnlyPropertiesOnce();
                  newNode.setProperty(propertyKey, convertedValue);
View Full Code Here


      PropertyKey referenceKeyProperty = StructrApp.getConfiguration().getPropertyKeyForJSONName(_data.getClass(), referenceKey);
      //return getEditModeValue(securityContext, renderContext, _data, referenceKeyProperty, defaultValue);
      Object value = _data.getProperty(referenceKeyProperty);

      PropertyConverter converter = referenceKeyProperty.inputConverter(securityContext);

      if (value != null && converter != null && !(referenceKeyProperty instanceof RelationProperty)) {

        try {
          value = converter.revert(value);

        } catch (Throwable t) {

          logger.log(Level.WARNING, "Unable to convert property {0} of node {1}: {2}", new Object[]{referenceKeyProperty, _data, t.getMessage()});
        }
View Full Code Here

              Node databaseNode = node.getNode();

              if (databaseNode.hasProperty(propertyToFix.dbName())) {

                // check value with property converter
                PropertyConverter converter = propertyToFix.databaseConverter(securityContext, node);
                if (converter != null) {

                  try {
                    Object value = databaseNode.getProperty(propertyToFix.dbName());
                    converter.revert(value);

                  } catch (ClassCastException cce) {

                    // exception, needs fix
                    String databaseName   = propertyToFix.dbName();
View Full Code Here

      if (searchValue != null && !StringUtils.isBlank(searchValue.toString())) {

        final App app                          = StructrApp.getInstance(securityContext);
        final PropertyKey key                  = notion.getPrimaryPropertyKey();
        final PropertyConverter inputConverter = key.inputConverter(securityContext);

        // transform search values using input convert of notion property
        final Object transformedValue          = inputConverter != null ? inputConverter.convert(searchValue) : searchValue;

        if (exactMatch) {

          Result<AbstractNode> result = app.nodeQuery(entityProperty.relatedType()).and(key, transformedValue).getResult();
View Full Code Here

    }

    if (applyConverter) {

      // apply property converters
      PropertyConverter converter = databaseConverter(securityContext, obj);
      if (converter != null) {

        try {
          value = converter.revert(value);

        } catch (Throwable t) {
         
          t.printStackTrace();
View Full Code Here

  }
 
  @Override
  public void setProperty(SecurityContext securityContext, final GraphObject obj, T value) throws FrameworkException {
   
    PropertyConverter converter = databaseConverter(securityContext, obj);
    final Object convertedValue;

    if (converter != null) {

      convertedValue = converter.convert(value);

    } else {

      convertedValue = value;
    }
View Full Code Here

              // allow to set new type
              if (key.equals("newType")) {
                key = "type";
              }

              PropertyConverter inputConverter = StructrApp.getConfiguration().getPropertyKeyForJSONName(cls, key).inputConverter(securityContext);


              if (inputConverter != null) {
                try {
                  val = inputConverter.convert(entry.getValue());
                } catch (FrameworkException ex) {
                  logger.log(Level.SEVERE, null, ex);
                }

              } else {
View Full Code Here

  }

  @Override
  public List<T> convertSearchValue(SecurityContext securityContext, String requestParameter) throws FrameworkException {

    final PropertyConverter inputConverter = inputConverter(securityContext);
    if (inputConverter != null) {

      final List<String> sources = new LinkedList<>();
      if (requestParameter != null) {

        for (String part : requestParameter.split("[,;]+")) {
          sources.add(part);
        }
      }

      return (List<T>)inputConverter.convert(sources);
    }

    return null;
  }
View Full Code Here

        Object value = entry.getValue();

        if (key != null) {

          PropertyKey propertyKey     = StructrApp.getConfiguration().getPropertyKeyForDatabaseName(entity.getClass(), key);
          PropertyConverter converter = propertyKey.databaseConverter(securityContext, entity);

          if (converter != null) {

            try {
              Object propertyValue = converter.convert(value);
              resultMap.put(propertyKey, propertyValue);

            } catch(ClassCastException cce) {

              cce.printStackTrace();
View Full Code Here

        Object value = entry.getValue();

        if (key != null) {

          PropertyKey propertyKey     = StructrApp.getConfiguration().getPropertyKeyForDatabaseName(entityType, key);
          PropertyConverter converter = propertyKey.databaseConverter(securityContext, entity);

          if (converter != null) {

            try {
              Object propertyValue = converter.revert(value);
              resultMap.put(propertyKey, propertyValue);

            } catch(ClassCastException cce) {

              cce.printStackTrace();
View Full Code Here

TOP

Related Classes of org.structr.core.converter.PropertyConverter

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.