Examples of SourceProperty


Examples of com.codiform.moo.property.source.SourceProperty

  private void copyToTargetCollection( Object value, Object target, CollectionProperty property ) {
    if ( value instanceof Collection ) {
      if ( target instanceof Collection ) {
        Collection<Object> targetCollection = (Collection<Object>)target;
        Iterator<?> sourceItems = ( (Collection<?>)value ).iterator();
        SourceProperty itemSource = getItemSource( property.getItemSource() );
        while ( sourceItems.hasNext() ) {
          Object item = itemSource.getValue( sourceItems.next() );
          targetCollection.add( item );
        }
      } else {
        throw new TranslationException( "Cannot translate collection to target of type: " + target.getClass().getName() );
      }
View Full Code Here

Examples of com.codiform.moo.property.source.SourceProperty

  private void translateToTargetCollection( Object value, Object target, CollectionProperty property, TranslationSource cache ) {
    if ( value instanceof Collection ) {
      if ( target instanceof Collection ) {
        Collection<Object> targetCollection = (Collection<Object>)target;
        Iterator<?> sourceItems = ( (Collection<?>)value ).iterator();
        SourceProperty itemSource = getItemSource( property.getItemSource() );
        while ( sourceItems.hasNext() ) {
          Object item = itemSource.getValue( sourceItems.next() );
          Object translated = cache.getTranslation( item, property.getItemClass() );
          targetCollection.add( translated );
        }
      } else {
        throw new TranslationException( "Cannot translate collection to target of type: " + target.getClass().getName() );
View Full Code Here

Examples of com.codiform.moo.property.source.SourceProperty

      throw new TranslationException( "Cannot translate map from type: " + value.getClass().getName() );
    }
  }

  private void translateMap( Map<Object, Object> source, Map<Object, Object> target, MapProperty property, TranslationSource translationSource ) {
    SourceProperty keySourceProperty = getSourceProperty( property.getKeySource() );
    SourceProperty valueSourceProperty = getSourceProperty( property.getValueSource() );
    for ( Map.Entry<Object, Object> entry : source.entrySet() ) {
      Object key, value;

      key = keySourceProperty.getValue( entry.getKey() );
      if ( key == null && !property.allowNullKeys() )
        continue;

      key = getKeyOrTranslation( key, property, translationSource );
      if ( key == null && !property.allowNullKeys() )
        continue;

      value = valueSourceProperty.getValue( entry.getValue() );
      value = getValueOrTranslation( value, property, translationSource );
      target.put( key, value );
    }
  }
View Full Code Here

Examples of com.codiform.moo.property.source.SourceProperty

    }
  }

  private void updateMapByKey( Map<Object, Object> sourceMap, Map<Object, Object> destinationMap, TranslationSource translationSource,
      MapProperty property ) {
    SourceProperty keySourceProperty = getSourceProperty( property.getKeySource() );
    SourceProperty valueSourceProperty = getSourceProperty( property.getValueSource() );

    for ( Map.Entry<Object, Object> entry : sourceMap.entrySet() ) {
      Object key = entry.getKey();
      key = keySourceProperty.getValue( key );
      if ( key == null && !property.allowNullKeys() )
        continue;

      key = getKeyOrTranslation( key, property, translationSource );
      if ( key == null && !property.allowNullKeys() )
        continue;

      Object sourceValue = entry.getValue();
      sourceValue = valueSourceProperty.getValue( sourceValue );
      sourceValue = getValueOrTranslation( sourceValue, property, translationSource );

      Object destinationValue = destinationMap.get( key );
      if ( destinationValue != null && sourceValue != null ) {
        translationSource.update( sourceValue, destinationValue );
View Full Code Here

Examples of com.codiform.moo.property.source.SourceProperty

  private Object transformCollection( Object value, CollectionProperty property, TranslationSource translationSource ) {
    return translatorFactory.getCollectionTranslator().translate( value, property, translationSource );
  }

  private Object getValue( Object source, Property property, Map<String, Object> variables ) {
    SourceProperty sourceProperty = sourcePropertyFactory.getSourceProperty( property.getSourcePropertyExpression() );
    if ( variables == null || variables.isEmpty() ) {
      return sourceProperty.getValue( source );
    } else {
      return sourceProperty.getValue( source, variables );
    }
  }
View Full Code Here

Examples of org.apache.cocoon.components.source.helpers.SourceProperty

            stmt = connection.prepareStatement(STMT_SELECT_ALL);
            stmt.setString(1,source.getURI());
            ResultSet result = stmt.executeQuery();
            List properties = new ArrayList();
            while (result.next()) {
                SourceProperty property = new SourceProperty(
                    result.getString(1),result.getString(2),result.getString(3));
                if (handlesProperty(property.getNamespace(),property.getName())) {
                    properties.add(property);
                }
            }
            result.close();
            stmt.close();
View Full Code Here

Examples of org.apache.cocoon.components.source.helpers.SourceProperty

            stmt = connection.prepareStatement(STMT_SELECT_SINGLE);
            stmt.setString(1,source.getURI());
            stmt.setString(2,namespace);
            stmt.setString(3,name);
            ResultSet result = stmt.executeQuery();
            SourceProperty property = null;
            if (result.next()) {
                property = new SourceProperty(
                    namespace,
                    name,
                    result.getString(1));
            }
            result.close();
View Full Code Here

Examples of org.apache.cocoon.components.source.helpers.SourceProperty

                try {
                    processor = (XPathProcessor)manager.lookup(XPathProcessor.ROLE);

                    NodeList nodelist = processor.selectNodeList(doc.getDocumentElement(), this.xpath);

                    SourceProperty property = new SourceProperty(this.propertynamespace, this.propertyname);
                    property.setValue(nodelist);

                    return property;
                } catch (ComponentException ce) {
                    this.getLogger().error("Could not retrieve component", ce);
                } finally {
View Full Code Here

Examples of org.apache.cocoon.components.source.helpers.SourceProperty

        return null
    }

    public SourceProperty[] getSourceProperties(Source source) throws SourceException {

        SourceProperty property = getSourceProperty(source, this.propertynamespace, this.propertyname);
        if (property!=null)
            return new SourceProperty[]{property};
        return null;
    }
View Full Code Here

Examples of org.apache.cocoon.components.source.helpers.SourceProperty

        if ((namespace.equals(PROPERTY_NS)) &&
            ((name.equals(IMAGE_WIDTH_PROPERTY_NAME)) || (name.equals(IMAGE_HEIGHT_PROPERTY_NAME))) &&
            (source.getURI().endsWith(".jpg")) && (isJPEGFile(source))) {

            if (name.equals(IMAGE_WIDTH_PROPERTY_NAME))
                return new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME,
                                          String.valueOf(getJpegSize(source)[0]));
            if (name.equals(IMAGE_HEIGHT_PROPERTY_NAME))
                return new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME,
                                          String.valueOf(getJpegSize(source)[1]));
        }
        return null
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.