Package nexj.core.util

Examples of nexj.core.util.PropertyMap


         Metadata metadata = new MetadataLoaderDispatcher().load(null, null,
            MetadataLoader.DATASOURCE_ONLY | MetadataLoader.INTEGRATION_EXCLUDED, null);
         RelationalDatabase database = getDatabase(metadata);

         manager = getSchemaManager(database);
         manager.createDatabase((RelationalSchema)database.getSchema(), new PropertyMap()
         {
            public Object findValue(String sName, Object defaultValue)
            {
               Object value = getValue(sName);
View Full Code Here


      {
         int nChildCount = source.getChildCount();

         if (nChildCount != 0)
         {
            PropertyMap tobj = (PropertyMap)obj;

            for (int nChild = 0; nChild != nChildCount; ++nChild)
            {
               TransformationSource child = source.getChild(nChild);
View Full Code Here

         audit.setValue("argCount", Primitive.createInteger(nArgCount));
         audit.setValue("user", context.getUser());

         if (nMode != AUDIT_NONE && (instance != null || nMode == AUDIT_MAP))
         {
            PropertyMap map = (PropertyMap)audit.getValue("values");

            for (PropertyIterator itr = tobj.getIterator(); itr.hasNext();)
            {
               itr.next();

               if (nMode <= AUDIT_MAP)
               {
                  Object value;

                  if (nMode == AUDIT_NAMES)
                  {
                     value = null;
                  }
                  else
                  {
                     value = itr.getValue();

                     if (!TextMarshaller.isSerializable(value))
                     {
                        value = String.valueOf(value);
                     }
                  }

                  map.setValue(itr.getName(), value);
               }
               else
               {
                  Attribute attr = instance.getMetaclass().findAttribute(itr.getName());

                  if (attr != null && !attr.isStatic() && attr.getVisibility() == Metaclass.PUBLIC)
                  {
                     Object value = instance.getValueDirect(attr.getOrdinal());

                     if (!(value instanceof Undefined))
                     {
                        if (!TextMarshaller.isSerializable(value))
                        {
                           value = String.valueOf(value);
                        }

                        if (nMode == AUDIT_VALUES)
                        {
                           if (value != null)
                           {
                              map.setValue(attr.getName(), value);
                           }
                        }
                        else
                        {
                           Object oldValue = instance.getOldValueDirect(attr.getOrdinal());

                           if (!ObjUtil.equal(value, oldValue))
                           {
                              map.setValue(attr.getName(), value);

                              if (!(oldValue instanceof Undefined))
                              {
                                 map.setValue('-' + attr.getName(), oldValue);
                              }
                           }
                        }
                     }
                  }
View Full Code Here

            instance.setValue("objectCaption", buf.toString());
         }
         else if (sName.equals("valuesCaption"))
         {
            PropertyMap valueMap = (PropertyMap)instance.getValue("values");
            StringBuffer buf = new StringBuffer(128);
            String sEvent = (String)instance.getValue("event");
            int nEvent = 0;
           
            if ("read".equals(sEvent))
            {
               nEvent = 2;
            }
            else if ("update".equals(sEvent))
            {
               nEvent = 1;
            }

            List nameList = new ArrayList();

            for (PropertyIterator itr = valueMap.getIterator(); itr.hasNext();)
            {
               String sValue = (String)itr.next();

               if (sValue.length() != 0 && sValue.charAt(0) != '-')
               {
                  nameList.add(sValue);
               }
            }
           
            Collections.sort(nameList, String.CASE_INSENSITIVE_ORDER);

            for (int i = 0; i != nameList.size(); ++i)
            {
               String sValue = (String)nameList.get(i);

               if (buf.length() != 0)
               {
                  buf.append(", ");
               }

               buf.append(sValue);

               switch (nEvent)
               {
                  case 0:
                     buf.append('=');
                     appendValue(buf, valueMap.getValue(sValue), true);
                     break;

                  case 1:
                     String sOldName = '-' + sValue;
                     Object oldValue = valueMap.getValue(sOldName);

                     if (oldValue != null || valueMap.hasValue(sOldName))
                     {
                        buf.append(": ");
                        appendValue(buf, valueMap.getValue(sOldName), true);
                        buf.append(" -> ");
                     }
                     else
                     {
                        buf.append('=');
                     }

                     appendValue(buf, valueMap.getValue(sValue), true);
                     break;
               }
            }

            instance.setValue("valuesCaption", buf.toString());
View Full Code Here

    * @return Map of default properties for a schema taking into consideration supplied defaults.
    */
   public PropertyMap getDefaultDatabaseProperties(RelationalSchema schema, PropertyMap config)
   {
      String sScriptName = getSetupEtcScriptName();
      PropertyMap propertyMap = new TransferObject();
      PropertyMap referenceMap = setDefaultDatabaseProperties(new TransferObject());

      for (PropertyIterator itr = referenceMap.getIterator(); itr.hasNext();)
      {
         itr.next();
         itr.setValue(null); // unset only default values so that they do not override custom later
      }

      setCustomDatabaseProperties(referenceMap, config);
      setMetadataDatabaseProperties(referenceMap, schema);

      if (sScriptName != null)
      {
         InputStream istream = null;

         try
         {
            istream = URLUtil.openResource(getClass(), "etc/" + sScriptName);
            setTemplateDefaults(propertyMap,
                                referenceMap,
                                new InputStreamReader(istream, XMLUtil.ENCODING),
                                schema.getMetadata().isTestEnvironment());
         }
         catch (Throwable t)
         {
            ObjUtil.rethrow(t);
         }
         finally
         {
            IOUtil.close(istream);
         }
      }

      PropertyMap defaultsMap = setDefaultDatabaseProperties(new TransferObject());

      // look for unset keys needing to be overridden with custom values or defaults
      for (PropertyIterator itr = propertyMap.getIterator(); itr.hasNext();)
      {
         String sKey = (String)itr.next();
         Object value = referenceMap.findValue(sKey);

         if (value != null ||
             (itr.getValue() == null && (value = defaultsMap.findValue(sKey)) != null))
         {
            itr.setValue(value); // override default in template with custom value in schema
         }
      }

View Full Code Here

         throw new IllegalStateException(); // this should not be user-triggerable
      }

      InputStream istream = null;
      StringWriter writer = new StringWriter();
      PropertyMap propertiesMap = new TransferObject();

      setCustomDatabaseProperties(propertiesMap, config);
      setMetadataDatabaseProperties(propertiesMap, schema);

      // check if any of the path parameters are in a Microsoft compatible format
View Full Code Here

   }

   public void testSetupDefaultProperties()
   {
      RelationalSchema schema = (RelationalSchema)m_database.getSchema();
      PropertyMap defaults = m_manager.getDefaultDatabaseProperties(schema, null);
      PropertyMap custom = m_manager.getDefaultDatabaseProperties(schema, defaults); // reinterpret

      assertEquals(defaults.getValueCount(), custom.getValueCount());

      // ensure all keys exist in both sets and non-null values are set for same keys
      for (Iterator itr = defaults.getIterator(); itr.hasNext();)
      {
         String sKey = (String)itr.next();

         assertTrue(defaults.getValue(sKey) == null || custom.getValue(sKey) != null);
      }
   }
View Full Code Here

      }
   }

   public void testSetupDefaultsExtractor() throws IOException
   {
      PropertyMap propertyMap = new TransferObject();
      PropertyMap referenceMap = new TransferObject();
      String input = "${validKey}${emptyKey}${multiKey:multiValue}${multiKey:multiValue2}"
                   + "${for-each:tablespace:${recurKey:recurValue1}}"
                   + "${for-each:tablespace:${recurKey:recurValue2}}"
                   + "${emptyKey:emptyValue}";

      referenceMap.setValue("validKey", null);
      referenceMap.setValue("multiKey", null);
      referenceMap.setValue("recurKey", null);
      referenceMap.setValue("emptyKey", null);
      propertyMap.setValue("validKey", "validValue");
      propertyMap.setValue("multiKey", "multiValue");
      propertyMap.setValue("recurKey", null);
      propertyMap.setValue("emptyKey", null);
      m_manager.setTemplateDefaults(propertyMap, referenceMap, new StringReader(input), true);
View Full Code Here

TOP

Related Classes of nexj.core.util.PropertyMap

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.