Package de.willuhn.datasource.db

Examples of de.willuhn.datasource.db.AbstractDBObjectNode


    try
    {
      reader = new XmlReader(is, new ObjectFactory() {
        public GenericObject create(String type, String id, Map values) throws Exception
        {
          AbstractDBObjectNode object = (AbstractDBObjectNode) Settings.getDBService().createObject(loader.loadClass(type),null);
          object.setID(id);
          Iterator i = values.keySet().iterator();
          while (i.hasNext())
          {
            String name = (String) i.next();
            object.setAttribute(name,values.get(name));
          }
          return object;
        }
     
      });
     
      if (monitor != null)
        monitor.setStatusText(i18n.tr("Lese Datei ein"));

      int created = 0;
      int error   = 0;

      Map<String,String> idMap = new HashMap<String,String>();
     
      AbstractDBObjectNode object = null;
      while ((object = (AbstractDBObjectNode) reader.read()) != null)
      {
        if (monitor != null)
        {
          monitor.log(i18n.tr("Datensatz {0}", "" + (created+1)));
          if (created > 0 && created % 10 == 0) // nur geschaetzt
            monitor.addPercentComplete(1);
        }

        try
        {
          String id = object.getID();
          object.setID(null);
         
          // Remap parent
          Object parent = object.getAttribute("parent_id");
          if (parent != null)
            object.setAttribute("parent_id",idMap.get(parent.toString()));
         
          object.store();
          idMap.put(id,object.getID());
          created++;
          try
          {
            Application.getMessagingFactory().sendMessage(new ImportMessage(object));
          }
View Full Code Here

TOP

Related Classes of de.willuhn.datasource.db.AbstractDBObjectNode

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.