Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.Transformation


         {
            logger.debug("Transforming a message with transformation " + transformation.getName());
            logger.dump(obj);
         }

         Transformation oldTransformation = transformation;

         if (!StringUtil.isEmpty(obj.getClassName()) && m_bPolymorphic)
         {
            TransformationEndpoint derivedEndpoint = transformation.getSource().getEndpoint(obj.getClassName());
            Transformation derivedTransformation = findDerivedTransformation(transformation, derivedEndpoint);

            if (oldTransformation.getDerivation() == Transformation.DERIVATION_FINAL && derivedTransformation != oldTransformation)
            {
               throw new IntegrationException("err.integration.messageTypeMismatch",
                  new Object[] {oldTransformation.toString(), oldTransformation.getSource().toString(), derivedEndpoint.toString()});
            }

            if (derivedTransformation != null && derivedTransformation != oldTransformation)
            {
               transformation = derivedTransformation;

               if (logger.isDebugEnabled())
               {
                  logger.debug("Using derived transformation \"" + derivedTransformation.getName() + "\"");
               }
            }
         }

         if (oldTransformation.getDerivation() == Transformation.DERIVATION_ABSTRACT)
View Full Code Here


    * @return The transformed message.
    * @throws IntegrationException If a transformation error occurs.
    */
   public TransferObject transformNested(PropertyMap tobj, String sTransformationName, Pair arguments) throws IntegrationException
   {
      Transformation transformation = m_context.getMetadata().getTransformation(sTransformationName);
      TransferObject outputSaved = m_output;
      Object[] sourceArraySaved = m_sourceArray;
      Lookup listMapSaved = m_listMap;
      ListKey listKeySaved = m_listKey;
      Object[] scriptArraySaved = m_scriptArray;
View Full Code Here

    */
   public static Transformation findDerivedTransformation(Transformation txf, TransformationEndpoint endpoint)
   {
      if (endpoint != null && txf.getDerivation() != Transformation.DERIVATION_FINAL)
      {
         Transformation result = txf.findTransformation(endpoint);

         if (result == null)
         {
            return findDerivedTransformation(txf, endpoint.getBaseEndpoint());
         }
View Full Code Here

   protected void seed(String sTransformation, final Function enabled, final Function delete, ResourceLoader loader)
   {
      final Metadata metadata = m_context.getMetadata();
      final MessageParser parser = (MessageParser)metadata.getFormat("XML").getParser().getInstance(m_context);
      final MessageFormatter formatter = (MessageFormatter)metadata.getFormat("Object").getFormatter().getInstance(m_context);
      final Transformation transformation = metadata.getTransformation(sTransformation);
      final Transformer transformer = new Transformer(m_context);
      final UnitOfWork uow = m_context.getUnitOfWork();
      final boolean bRawSaved = uow.isRaw();

      try
      {
         uow.setRaw(true);

         final List tobjList = new ArrayList();

         loader.seedResources(((XMLMetadata)metadata).getHelper(), new CharacterStreamHandler()
         {
            public void handleCharacterStream(Reader reader, String sName) throws IOException
            {
               try
               {
                  TransferObject tobj = parser.parse(new ReaderInput(reader), (Message)transformation.getSource());

                  tobj.setValue("name", sName);

                  if (enabled != null && !Intrinsic.isTrue(m_context.getMachine().invoke(enabled, tobj, (Object[])null)))
                  {
                     return;
                  }

                  if (delete != null)
                  {
                     m_context.getMachine().invoke(delete, tobj, (Object[])null);
                  }

                  tobj = transformer.transform(tobj, transformation);
                  tobjList.add(tobj);
               }
               catch (Exception e)
               {
                  s_logger.error("Unable to seed resource \"" + sName + "\"", e);

                  if (e instanceof RuntimeException)
                  {
                     throw (RuntimeException)e;
                  }

                  throw new UncheckedException("err.runtime.seed", new Object[]{sName}, e);
               }
            }
         });

         // Commit the deletes
         uow.commit(false);

         for (Iterator itr = tobjList.iterator(); itr.hasNext();)
         {
            formatter.format((TransferObject)itr.next(), (Message)transformation.getDestination(), new ObjectOutput());
         }

         // Commit the inserts/updates
         uow.commit(false);
      }
View Full Code Here

         m_helper.fixup(m_postInheritanceTransformationFixupList.iterator());
         m_postInheritanceTransformationFixupList = null;

         for (Iterator itr = m_metadata.getTransformationIterator(); itr.hasNext(); )
         {
            Transformation transformation = (Transformation)itr.next();

            try
            {
               transformation.finish(m_machine);
            }
            catch (UncheckedException ex)
            {
               m_helper.addException(ex);
            }
View Full Code Here

    */
   protected void loadTransformation(Element transformationElement, String sName)
   {
      XMLMetadataHelper.verifyRootElement(transformationElement, "Transformation");

      final Transformation transformation = new Transformation(sName);
      final String sURLPrefix = "transformation:" + sName;

      transformation.setCategory(XMLUtil.getStringAttr(transformationElement, "category"));
      transformation.setResourceName(m_helper.getCurResourceName());
      transformation.setSource(getTransformationEndpoint(XMLUtil.getReqStringAttr(transformationElement, "source"), sName));
      transformation.setDestination(getTransformationEndpoint(XMLUtil.getReqStringAttr(transformationElement, "destination"), sName));

      String sArguments = XMLUtil.getStringAttr(transformationElement, "args");

      if (sArguments != null)
      {
         StringTokenizer tokenizer = new StringTokenizer(sArguments);

         while (tokenizer.hasMoreTokens())
         {
            transformation.addArgument(tokenizer.nextToken());
         }
      }

      final String sBase = XMLUtil.getStringAttr(transformationElement, "base");

      if (sBase != null)
      {
         addTransformationFixup(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               Transformation baseTransformation = m_metadata.getTransformation(sBase);

               transformation.setBaseTransformation(baseTransformation);
               baseTransformation.addDerivedTransformation(transformation);
            }
         });
      }

      String sDerivation = XMLUtil.getStringAttr(transformationElement, "derivation", "virtual");
View Full Code Here

    * @return The transformation object.
    * @throws MetadataLookupException if the transformation does not exist.
    */
   public Transformation getTransformation(String sName)
   {
      Transformation transformation = (Transformation) m_transformationMap.get(sName);

      if (transformation != null)
      {
         return transformation;
      }
View Full Code Here

TOP

Related Classes of nexj.core.meta.integration.Transformation

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.