Package org.structr.core.converter

Examples of org.structr.core.converter.PropertyConverter


    }

    public void serializeProperty(RestWriter writer, PropertyKey key, Object value, String localPropertyView, int depth) {

      try {
        PropertyConverter converter = key.inputConverter(writer.getSecurityContext());

        if (converter != null) {

          Object convertedValue = null;

          // ignore conversion errors
          try { convertedValue = converter.revert(value); } catch (Throwable t) {}

          serializeRoot(writer, convertedValue, localPropertyView, depth);

        } else {
View Full Code Here


    }

    public JsonElement serializeProperty(PropertyKey key, Object value, String localPropertyView, int depth) {

      try {
        PropertyConverter converter = key.inputConverter(securityContext);

        if (converter != null) {

          return serializeRoot(converter.revert(value), localPropertyView, depth);

        } else {

          return serializeRoot(value, localPropertyView, depth);
        }
View Full Code Here

  /**
   * Test of databaseConverter method, of class EntityProperty.
   */
  public void testDatabaseConverter() {

    PropertyConverter expResult = null;
    PropertyConverter result = TestSix.oneToOneTestThree.databaseConverter(securityContext, null);
    assertEquals(expResult, result);
  }
View Full Code Here

  /**
   * Test of inputConverter method, of class EntityProperty.
   */
  public void testInputConverter() {

    PropertyConverter result = TestSix.oneToOneTestThree.inputConverter(securityContext);
   
    assertTrue(result != null);
  }
View Full Code Here

   * Test of databaseConverter method, of class CollectionProperty.
   */
  public void testDatabaseConverter() {

    Property<List<TestOne>> instance = TestSix.manyToManyTestOnes;
    PropertyConverter expResult = null;
    PropertyConverter result = instance.databaseConverter(securityContext, null);
    assertEquals(expResult, result);
  }
View Full Code Here

   * Test of inputConverter method, of class CollectionProperty.
   */
  public void testInputConverter() {

    Property<List<TestOne>> instance = TestSix.manyToManyTestOnes;
    PropertyConverter result = instance.inputConverter(securityContext);
   
    assertTrue(result != null);
  }
View Full Code Here

    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[] {
View Full Code Here

    if (key != null) {

      final T propertyValue = getProperty(key, false, null)// get "raw" property without converter

      // check property converter
      PropertyConverter converter = key.databaseConverter(securityContext, this);
      if (converter != null) {

        try {
          return converter.convertForSorting(propertyValue);

        } catch(FrameworkException fex) {
          logger.log(Level.WARNING, "Unable to convert property {0} of type {1}: {2}", new Object[] {
            key.dbName(),
            getClass().getSimpleName(),
View Full Code Here

    String key = (String) webSocketData.getNodeData().get("key");

    if (node != null) {

      PropertyKey propertyKey = StructrApp.getConfiguration().getPropertyKeyForJSONName(node.getClass(), key);
      PropertyConverter converter = propertyKey.inputConverter(getWebSocket().getSecurityContext());

      Object value = node.getProperty(propertyKey);
      if (converter != null) {

        try {
          value = converter.revert(value);

        } catch (FrameworkException ex) {
         
          getWebSocket().send(MessageBuilder.status().code(400).message(ex.getMessage()).build(), true);
View Full Code Here

        propProperties.put("type", property.typeName());
      }
      propProperties.put("isCollection", property.isCollection());

      final PropertyConverter databaseConverter = property.databaseConverter(securityContext, null);
      final PropertyConverter inputConverter = property.inputConverter(securityContext);

      if (databaseConverter != null) {

        propProperties.put("databaseConverter", databaseConverter.getClass().getName());
      }

      if (inputConverter != null) {

        propProperties.put("inputConverter", inputConverter.getClass().getName());
      }

      //if (declaringClass != null && ("org.structr.dynamic".equals(declaringClass.getPackage().getName()))) {
      if (declaringClass != null && property instanceof RelationProperty) {
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.