Package nexj.core.meta.integration.format.object

Examples of nexj.core.meta.integration.format.object.ObjectMessagePartMapping


      {
         MessagePart part = composite.getPart(i);

         if (tobj.hasValue(part.getName()))
         {
            ObjectMessagePartMapping partMapping = (ObjectMessagePartMapping)part.getMapping();

            if (isUpdateRequired(partMapping, instance, bNew))
            {
               Object value = instantiate(tobj.getValue(part.getName()), part);
               Attribute attribute = partMapping.getAttribute();

               if (attribute == null || instance == null)
               {
                  if (partMapping.getSystemAttribute() == ObjectMessagePartMapping.ATTR_OID)
                  {
                     if (value != null && !(value instanceof OID))
                     {
                        instance.setOID(OID.fromBinary(Primitive.toBinary(value)));
                     }
                     else
                     {
                        instance.setOID((OID)value);
                     }
                  }

                  continue;
               }

               if (bNew)
               {
                  instance.setValue(attribute.getOrdinal(), value);
               }
               else
               {
                  if (conflictResolution != null &&
                     !conflictResolution.shouldUpdate(instance, attribute, value))
                  {
                     continue;
                  }

                  if (attribute.isCollection())
                  {
                     InstanceList list = (InstanceList)instance.getValue(attribute.getOrdinal());
                     InstanceList valueList = (InstanceList)value;

                     for (int l = 0; l < valueList.size(); ++l)
                     {
                        Instance newInst = valueList.getInstance(l);

                        if (!list.contains(newInst))
                        {
                           list.add(newInst);
                        }
                     }
                  }
                  else if (!partMapping.isKey() && !ObjUtil.equal(instance.getValue(attribute.getOrdinal()), value))
                  {
                     instance.setValue(attribute.getOrdinal(), value);
                  }
               }
            }
View Full Code Here


      boolean bSameValues = true;

      for (int nPartIndex = 0, nPartCount = composite.getPartCount(); nPartIndex != nPartCount; ++nPartIndex)
      {
         MessagePart part = composite.getPart(nPartIndex);
         ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)part.getMapping();
         String sName = part.getName();

         if (newTobj.hasValue(sName) || oldTobj.hasValue(sName))
         {
            boolean bDifferent = newTobj.hasValue(sName) != oldTobj.hasValue(sName);

            if (!bDifferent)
            {
               if (part instanceof CompositeMessagePart && !part.isCollection())
               {
                  CompositeMessagePart derivedMessagePart = getPolymorphic((CompositeMessagePart)part, newTobj,
                     context);

                  bDifferent = !isSameKey((TransferObject)oldTobj.getValue(sName),
                     (TransferObject)newTobj.getValue(sName), derivedMessagePart, context);
               }
               else
               {
                  bDifferent = !ObjUtil.equal(oldTobj.getValue(sName), newTobj.getValue(sName));
               }
            }

            // OID attribute might not be populated;
            bSameValues = bSameValues && (!bDifferent
               || mapping.getSystemAttribute() == ObjectMessagePartMapping.ATTR_OID);

            if (mapping.isKey())
            {
               bKeyIsPresent = true;
               bSameKey = bSameKey && !bDifferent;
            }
         }
View Full Code Here

      Message surgeonMsg2 = new Message("SurgeonMessage2");
      CompositeMessagePartInstance contactPart = new CompositeMessagePartInstance(contactMsg.getName());
      CompositeMessagePartInstance doctorPart = new CompositeMessagePartInstance(doctorMsg.getName());
      CompositeMessagePartInstance surgeonPart1 = new CompositeMessagePartInstance(surgeonMsg1.getName());
      CompositeMessagePartInstance surgeonPart2 = new CompositeMessagePartInstance(surgeonMsg2.getName());
      ObjectMessagePartMapping contactMapping = new ObjectMessagePartMapping();
      ObjectMessagePartMapping doctorMapping = new ObjectMessagePartMapping();
      ObjectMessagePartMapping surgeonMapping1 = new ObjectMessagePartMapping();
      ObjectMessagePartMapping surgeonMapping2 = new ObjectMessagePartMapping();

      contactMsg.setRoot(contactPart);
      doctorMsg.setRoot(doctorPart);
      surgeonMsg1.setRoot(surgeonPart1);
      surgeonMsg2.setRoot(surgeonPart2);

      contactPart.setDeclarator(contactMsg);
      doctorPart.setDeclarator(doctorMsg);
      surgeonPart1.setDeclarator(surgeonMsg1);
      surgeonPart2.setDeclarator(surgeonMsg2);

      doctorMsg.setBaseMessage(contactMsg);
      contactMsg.addDerivedMessage(doctorMsg);
      surgeonMsg1.setBaseMessage(doctorMsg);
      doctorMsg.addDerivedMessage(surgeonMsg1);
      surgeonMsg2.setBaseMessage(doctorMsg);
      doctorMsg.addDerivedMessage(surgeonMsg2);

      contactPart.setMapping(contactMapping);
      doctorPart.setMapping(doctorMapping);
      surgeonPart1.setMapping(surgeonMapping1);
      surgeonPart2.setMapping(surgeonMapping2);

      contactMapping.setMetaclass(contactClass);
      doctorMapping.setMetaclass(doctorClass);
      surgeonMapping1.setMetaclass(surgeonClass);
      surgeonMapping2.setMetaclass(surgeonClass);

      contactMapping.init(contactPart);
      doctorMapping.init(doctorPart);
      surgeonMapping1.init(surgeonPart1);
      surgeonMapping2.init(surgeonPart2);

      contactMapping.finish(contactPart);
      doctorMapping.finish(doctorPart);
      surgeonMapping1.finish(surgeonPart1);
      surgeonMapping2.finish(surgeonPart2);

      assertEquals(contactMsg, contactMapping.findMessage(contactClass));
      assertEquals(doctorMsg, contactMapping.findMessage(doctorClass));
      assertEquals(doctorMsg, contactMapping.findMessage(surgeonClass));
      assertEquals(doctorMsg, doctorMapping.findMessage(surgeonClass));
      assertEquals(surgeonMsg1, surgeonMapping1.findMessage(surgeonClass));
      assertEquals(surgeonMsg2, surgeonMapping2.findMessage(surgeonClass));

      assertNull(doctorMapping.findMessage(contactClass));
      assertNull(surgeonMapping1.findMessage(contactClass));
      assertNull(surgeonMapping1.findMessage(doctorClass));
      assertNull(surgeonMapping2.findMessage(contactClass));
      assertNull(surgeonMapping2.findMessage(doctorClass));

      assertEquals(contactMsg, ObjectMessageParser.findDerivedMessage(contactMsg, specialClass));
      assertNull(ObjectMessageParser.findDerivedMessage(doctorMsg, specialClass));

      assertEquals(doctorMsg, ObjectMessageParser.findDerivedMessage(contactMsg, doctorClass));
View Full Code Here

TOP

Related Classes of nexj.core.meta.integration.format.object.ObjectMessagePartMapping

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.