umongo

16:53:48.341 INFO  jd.cli.Main - Decompiling umongo.jar
package com.edgytech.umongo;

 enum AppPreferences$Item
{
  getMoreSize,  inlineDocumentLength,  useSystemLook,  treeUpdateRate;
  
  private AppPreferences$Item() {}
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.AppPreferences.Item
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.CheckBox;
import com.edgytech.swingfast.FormDialog;
import com.edgytech.swingfast.FormDialogListener;
import com.edgytech.swingfast.IntFieldInterface;

public class AppPreferences
  extends FormDialog
  implements FormDialogListener
{
  static enum Item
  {
    getMoreSize,  inlineDocumentLength,  useSystemLook,  treeUpdateRate;
    
    private Item() {}
  }
  
  public AppPreferences()
  {
    setEnumBinding(Item.values(), null);
  }
  
  public void start()
  {
    formOkCbk();
  }
  
  public void formOkCbk() {}
  
  public void formCancelCbk() {}
  
  public void formResetCbk() {}
  
  public boolean getUseSystemLook()
  {
    return ((CheckBox)getBoundUnit(Item.useSystemLook)).getBooleanValue();
  }
  
  public int getGetMoreSize()
  {
    return ((IntFieldInterface)getBoundUnit(Item.getMoreSize)).getIntValue();
  }
  
  public int getInlineDocumentLength()
  {
    return ((IntFieldInterface)getBoundUnit(Item.inlineDocumentLength)).getIntValue();
  }
  
  public int getTreeUpdateRate()
  {
    return ((IntFieldInterface)getBoundUnit(Item.treeUpdateRate)).getIntValue();
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.AppPreferences
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

 enum AutoUpdateDialog$Item
{
  autoType,  autoInterval,  autoCount;
  
  private AutoUpdateDialog$Item() {}
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.AutoUpdateDialog.Item
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.FormDialog;

public class AutoUpdateDialog
  extends FormDialog
{
  static enum Item
  {
    autoType,  autoInterval,  autoCount;
    
    private Item() {}
  }
  
  public AutoUpdateDialog()
  {
    setEnumBinding(Item.values(), null);
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.AutoUpdateDialog
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.edgytech.swingfast.Zone;

public class BasePanel
  extends Zone
{
  BaseTreeNode node;
  
  public BaseTreeNode getNode()
  {
    return node;
  }
  
  public void setNode(BaseTreeNode node)
  {
    this.node = node;
  }
  
  public void refresh()
  {
    refresh(null);
  }
  
  public void refresh(ButtonBase button)
  {
    if (node == null) {
      return;
    }
    node.structureComponent();
    updateComponent();
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.BasePanel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.SwingFast;
import com.edgytech.swingfast.Tree;
import com.edgytech.swingfast.TreeNodeLabel;
import com.edgytech.swingfast.XmlUnit;
import com.mongodb.MongoException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.tree.DefaultMutableTreeNode;

public abstract class BaseTreeNode
  extends TreeNodeLabel
{
  ImageIcon cachedIcon;
  boolean hasExpanded = false;
  private Set<String> overlays = new HashSet();
  
  protected void structureComponentCustom(JComponent old)
  {
    long time = System.currentTimeMillis();
    
    removeAllChildren();
    try
    {
      XmlUnit parent = getParent();
      if (((parent instanceof Tree)) || (hasExpanded))
      {
        populateChildren();
        UMongo.instance.addNodeToRefresh(this);
      }
    }
    catch (Exception e)
    {
      getLogger().log(Level.WARNING, e.getMessage(), e);
    }
    super.structureComponentCustom(old);
  }
  
  protected void updateComponentCustom(JComponent comp)
  {
    updateNode();
    
    cachedIcon = SwingFast.createIcon(icon, iconGroup);
    if (overlays.size() > 0)
    {
      List<ImageIcon> icons = new ArrayList();
      for (String str : overlays) {
        icons.add(SwingFast.createIcon(str, iconGroup));
      }
      cachedIcon = SwingFast.createOverlayIcon(cachedIcon, icons);
    }
    long time = System.currentTimeMillis();
    super.updateComponentCustom(comp);
  }
  
  void refresh()
  {
    clearOverlays();
    try
    {
      refreshNode();
    }
    catch (MongoException e)
    {
      if ((e.getCode() == 10057) || (e.getMessage().startsWith("unauthorized"))) {
        addOverlay("overlay/lock.png");
      } else {
        addOverlay("overlay/error.png");
      }
      getLogger().log(Level.FINE, null, e);
    }
    catch (Exception e)
    {
      addOverlay("overlay/error.png");
      getLogger().log(Level.FINE, null, e);
    }
  }
  
  public TreeNodeLabel getParentNode()
  {
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode)getTreeNode().getParent();
    if (parent == null) {
      return null;
    }
    return (TreeNodeLabel)parent.getUserObject();
  }
  
  protected abstract void populateChildren();
  
  public void removeNode()
  {
    TreeNodeLabel parent = getParentNode();
    parent.removeChild(this);
    parent.structureComponent();
  }
  
  public void handleNodeSelection()
  {
    UMongo.instance.displayNode(this);
  }
  
  public Icon getIcon()
  {
    return cachedIcon;
  }
  
  protected abstract void updateNode();
  
  protected abstract void refreshNode();
  
  void clearOverlays()
  {
    overlays.clear();
  }
  
  void addOverlay(String str)
  {
    overlays.add(str);
  }
  
  public void handleWillExpand()
  {
    if (!hasExpanded)
    {
      hasExpanded = true;
      
      structureComponent();
    }
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.BaseTreeNode
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.XmlUnit.Serial;
import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.Mongo;

public class CmdField
  extends DocField
{
  @XmlUnit.Serial
  public String cmd;
  @XmlUnit.Serial
  public String db;
  DB theDb;
  DBObject theCmd;
  
  public CmdField()
  {
    db = "admin";
  }
  
  public void addView()
  {
    new DbJobCmd(theDb, theCmd).addJob();
  }
  
  void updateFromCmd(DB db)
  {
    theDb = db;
    if (cmd == null) {
      return;
    }
    updateFromCmd(db, new BasicDBObject(cmd, Integer.valueOf(1)));
  }
  
  void updateFromCmd(DB db, DBObject cmd)
  {
    theDb = db;
    theCmd = cmd;
    if ((theDb == null) || (theCmd == null)) {
      return;
    }
    CommandResult res = db.command(cmd, db.getOptions());
    setDoc(res);
  }
  
  void updateFromCmd(Mongo mongo)
  {
    if (db == null) {
      return;
    }
    updateFromCmd(mongo.getDB(db));
  }
  
  void updateFromCmd(DBCollection col)
  {
    updateFromCmd(col.getDB(), new BasicDBObject(cmd, col.getName()));
  }
  
  public String getCmd()
  {
    return cmd;
  }
  
  public String getDB()
  {
    return db;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CmdField
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.io.IOException;
import javax.swing.tree.DefaultMutableTreeNode;
import org.xml.sax.SAXException;

public class CollectionNode
  extends BaseTreeNode
{
  DBCollection collection;
  BasicDBObject stats;
  
  public CollectionNode(DBCollection collection)
    throws IOException, SAXException
  {
    this.collection = collection;
    xmlLoad(Resource.getXmlDir(), Resource.File.collectionNode, null);
    markStructured();
  }
  
  public DBCollection getCollection()
  {
    return collection;
  }
  
  public DbNode getDbNode()
  {
    return (DbNode)((DefaultMutableTreeNode)getTreeNode().getParent()).getUserObject();
  }
  
  protected void populateChildren()
  {
    for (DBObject index : collection.getIndexInfo()) {
      addChild(new IndexNode(collection, index));
    }
  }
  
  protected void updateNode()
  {
    label = collection.getName();
    if (stats != null)
    {
      label = (label + " (" + stats.getLong("count") + "/" + stats.getLong("size") + ")");
      if (stats.getBoolean("sharded")) {
        addOverlay("overlay/superman.png");
      }
    }
  }
  
  protected void refreshNode()
  {
    CommandResult res = collection.getStats();
    res.throwOnError();
    stats = res;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionNode
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;

class CollectionPanel$1
  extends DbJob
{
  CollectionPanel$1(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, DBObject paramDBObject1, DBObject paramDBObject2, int paramInt1, int paramInt2, DBObject paramDBObject3, int paramInt3, DBObject paramDBObject4, boolean paramBoolean, ButtonBase paramButtonBase) {}
  
  public Object doRun()
  {
    DBCursor cur = val$col.find(val$query, val$fields, val$skip, val$batchSize);
    if (val$sort != null) {
      cur.sort(val$sort);
    }
    if (val$limit > 0) {
      cur.limit(val$limit);
    }
    if (val$hint != null) {
      cur.hint(val$hint);
    }
    if (val$explain) {
      return cur.explain();
    }
    return cur;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Find";
  }
  
  public Object getRoot(Object result)
  {
    if ((result == null) || (!(result instanceof DBCursor))) {
      return null;
    }
    return ((DBCursor)result).toString();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

class CollectionPanel$10
  extends DbJob
{
  CollectionPanel$10(CollectionPanel paramCollectionPanel, int paramInt, BasicDBObject paramBasicDBObject, boolean paramBoolean, DBCollection paramDBCollection, ButtonBase paramButtonBase) {}
  
  public Object doRun()
    throws IOException
  {
    List<DBObject> list = new ArrayList();
    for (int i = 0; i < val$count; i++)
    {
      BasicDBObject newdoc = (BasicDBObject)val$doc.copy();
      CollectionPanel.access$000(this$0, newdoc);
      if (val$bulk)
      {
        if (list.size() > 1000)
        {
          val$col.insert(list);
          list.clear();
        }
        list.add(newdoc);
      }
      else
      {
        val$col.insert(new DBObject[] { newdoc });
      }
    }
    if (val$bulk) {
      return val$col.insert(list);
    }
    return null;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Insert";
  }
  
  public Object getRoot(Object result)
  {
    return val$doc.toString();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.10
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.io.IOException;

class CollectionPanel$11
  extends DbJob
{
  CollectionPanel$11(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, BasicDBObject paramBasicDBObject, ButtonBase paramButtonBase) {}
  
  public Object doRun()
    throws IOException
  {
    return val$col.save((DBObject)val$doc.copy());
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Save";
  }
  
  public Object getRoot(Object result)
  {
    return val$doc.toString();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.11
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import java.io.IOException;

class CollectionPanel$12
  extends DbJob
{
  CollectionPanel$12(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, BasicDBObject paramBasicDBObject, ButtonBase paramButtonBase) {}
  
  public Object doRun()
    throws IOException
  {
    return val$col.remove(val$doc);
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Remove";
  }
  
  public Object getRoot(Object result)
  {
    return val$doc.toString();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.12
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.io.IOException;

class CollectionPanel$13
  extends DbJob
{
  CollectionPanel$13(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, DBObject paramDBObject1, DBObject paramDBObject2, ButtonBase paramButtonBase) {}
  
  public Object doRun()
    throws IOException
  {
    val$col.ensureIndex(val$keys, val$opts);
    return null;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Ensure Index";
  }
  
  public void wrapUp(Object res)
  {
    super.wrapUp(res);
    node.structureComponent();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.13
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.io.IOException;

class CollectionPanel$14
  extends DbJob
{
  CollectionPanel$14(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, DBObject paramDBObject, int paramInt1, int paramInt2, ButtonBase paramButtonBase) {}
  
  public Object doRun()
    throws IOException
  {
    return Long.valueOf(val$col.getCount(val$query, null, val$limit, val$skip));
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Count";
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.14
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;

class CollectionPanel$15
  extends DbJob
{
  CollectionPanel$15(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, DBObject paramDBObject1, DBObject paramDBObject2, DBObject paramDBObject3, boolean paramBoolean1, BasicDBObject paramBasicDBObject, boolean paramBoolean2, boolean paramBoolean3, ButtonBase paramButtonBase) {}
  
  public Object doRun()
  {
    return val$col.findAndModify(val$query, val$fields, val$sort, val$remove, (DBObject)val$update.copy(), val$returnNew, val$upsert);
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "FindAndMod";
  }
  
  public Object getRoot(Object result)
  {
    StringBuilder sb = new StringBuilder();
    sb.append("query=").append(val$query);
    sb.append(", fields=").append(val$fields);
    sb.append(", sort=").append(val$sort);
    sb.append(", update=").append(val$update);
    sb.append(", remove=").append(val$remove);
    sb.append(", returnNew=").append(val$returnNew);
    sb.append(", upsert=").append(val$upsert);
    return sb.toString();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.15
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.edgytech.swingfast.ConfirmDialog;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;

class CollectionPanel$16
  extends DbJob
{
  CollectionPanel$16(CollectionPanel paramCollectionPanel, boolean paramBoolean1, DBCollection paramDBCollection, DBObject paramDBObject, boolean paramBoolean2, BasicDBObject paramBasicDBObject, boolean paramBoolean3, ButtonBase paramButtonBase) {}
  
  public Object doRun()
  {
    if (val$safe)
    {
      long count = val$col.getCount(val$query);
      long toupdate = count > 0L ? 1L : 0L;
      if (val$multi) {
        toupdate = count;
      }
      String text = "Proceed with updating " + toupdate + " of " + count + " documents?";
      ConfirmDialog confirm = new ConfirmDialog(null, "Confirm Update", null, text);
      if (!confirm.show()) {
        return null;
      }
    }
    return val$col.update(val$query, (DBObject)val$update.copy(), val$upsert, val$multi);
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Update";
  }
  
  public Object getRoot(Object result)
  {
    StringBuilder sb = new StringBuilder();
    sb.append("query=").append(val$query);
    sb.append(", update=").append(val$update);
    sb.append(", upsert=").append(val$upsert);
    sb.append(", multi=").append(val$multi);
    return sb.toString();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.16
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

class CollectionPanel$17
  extends DbJob
{
  CollectionPanel$17(CollectionPanel paramCollectionPanel, boolean paramBoolean1, DBCollection paramDBCollection, DocumentDeserializer paramDocumentDeserializer, boolean paramBoolean2, String[] paramArrayOfString, boolean paramBoolean3, boolean paramBoolean4, ButtonBase paramButtonBase) {}
  
  public Object doRun()
    throws Exception
  {
    try
    {
      if (val$dropCollection) {
        val$col.drop();
      }
      DBObject obj = null;
      List<DBObject> batch = new ArrayList();
      while ((obj = val$dd.readObject()) != null) {
        try
        {
          if (val$upsert)
          {
            if (val$upsertFields == null)
            {
              val$col.save(obj);
            }
            else
            {
              BasicDBObject query = new BasicDBObject();
              for (int i = 0; i < val$upsertFields.length; i++)
              {
                String field = val$upsertFields[i];
                if (!obj.containsField(field)) {
                  throw new Exception("Upsert field " + field + " not present in object " + obj.toString());
                }
                query.put(field, obj.get(field));
              }
              val$col.update(query, obj, true, false);
            }
          }
          else if (val$bulk)
          {
            if (batch.size() > 1000)
            {
              val$col.insert(batch);
              batch.clear();
            }
            batch.add(obj);
          }
          else
          {
            val$col.insert(new DBObject[] { obj });
          }
        }
        catch (Exception e)
        {
          if (val$continueOnError) {
            getLogger().log(Level.WARNING, null, e);
          } else {
            throw e;
          }
        }
      }
      if (!batch.isEmpty()) {
        val$col.insert(batch);
      }
    }
    finally
    {
      val$dd.close();
    }
    return null;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Import";
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.17
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MongoException.DuplicateKey;

class CollectionPanel$18
  extends DbJob
{
  CollectionPanel$18(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection1, boolean paramBoolean, DBCollection paramDBCollection2) {}
  
  public Object doRun()
  {
    DBCursor cur = val$srcCol.find();
    int count = 0;
    int dup = 0;
    while (cur.hasNext())
    {
      DBObject obj = cur.next();
      if (val$upsert)
      {
        BasicDBObject id = new BasicDBObject("_id", obj.get("_id"));
        val$dstCol.update(id, obj, true, false);
      }
      else
      {
        try
        {
          val$dstCol.insert(new DBObject[] { obj });
        }
        catch (MongoException.DuplicateKey e)
        {
          dup++;
        }
      }
      count++;
    }
    DBObject res = new BasicDBObject("count", Integer.valueOf(count));
    res.put("dups", Integer.valueOf(dup));
    return res;
  }
  
  public String getNS()
  {
    return "*";
  }
  
  public String getShortName()
  {
    return "Fix Collection";
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.18
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;

class CollectionPanel$2
  extends DbJob
{
  CollectionPanel$2(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, DBObject paramDBObject1, DBObject paramDBObject2, ButtonBase paramButtonBase) {}
  
  public Object doRun()
  {
    return val$col.findOne(val$query, val$fields);
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "FindOne";
  }
  
  public Object getRoot(Object result)
  {
    return "query=" + val$query + ", fields=" + val$fields;
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.TreeNodeLabel;
import com.mongodb.DBCollection;

class CollectionPanel$3
  extends DbJob
{
  CollectionPanel$3(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, String paramString, boolean paramBoolean, CollectionNode paramCollectionNode) {}
  
  public Object doRun()
  {
    val$col.rename(val$name, val$dropTarget);
    return null;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Rename";
  }
  
  public Object getRoot(Object result)
  {
    return val$col.getName() + " to " + val$name;
  }
  
  public void wrapUp(Object res)
  {
    super.wrapUp(res);
    TreeNodeLabel node = val$colNode.getParentNode();
    if (node != null) {
      node.structureComponent();
    }
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.DBCollection;
import com.mongodb.GroupCommand;

class CollectionPanel$4
  extends DbJob
{
  CollectionPanel$4(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, GroupCommand paramGroupCommand, ButtonBase paramButtonBase) {}
  
  public Object doRun()
  {
    return val$col.group(val$cmd);
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Group";
  }
  
  public Object getRoot(Object result)
  {
    return val$cmd.toDBObject();
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MapReduceCommand;
import com.mongodb.MapReduceCommand.OutputType;
import com.mongodb.MapReduceOutput;

class CollectionPanel$5
  extends DbJob
{
  MapReduceOutput output;
  
  CollectionPanel$5(CollectionPanel paramCollectionPanel, MapReduceCommand.OutputType paramOutputType, DBCollection paramDBCollection, BasicDBObject paramBasicDBObject, MapReduceCommand paramMapReduceCommand, ButtonBase paramButtonBase) {}
  
  public Object doRun()
  {
    CommandResult res = null;
    if (val$type == MapReduceCommand.OutputType.INLINE)
    {
      res = val$col.getDB().command(val$cmdobj, val$col.getOptions());
      return res;
    }
    res = val$col.getDB().command(val$cmdobj);
    res.throwOnError();
    output = new MapReduceOutput(val$col, val$cmdobj, res);
    return output;
  }
  
  public void wrapUp(Object res)
  {
    if (output != null) {
      if (val$cmd.getOutputType() == MapReduceCommand.OutputType.INLINE)
      {
        res = output.results();
      }
      else
      {
        CollectionPanel.doFind(output.getOutputCollection(), null);
        res = output.getRaw();
      }
    }
    super.wrapUp(res);
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "MR";
  }
  
  public Object getRoot(Object result)
  {
    return val$cmdobj;
  }
  
  public ButtonBase getButton()
  {
    return val$button;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;

final class CollectionPanel$6
  extends DbJob
{
  CollectionPanel$6(DBCollection paramDBCollection, DBObject paramDBObject1, DBObject paramDBObject2, int paramInt1, int paramInt2, DBObject paramDBObject3, int paramInt3, DBObject paramDBObject4, boolean paramBoolean) {}
  
  public Object doRun()
  {
    DBCursor cur = val$col.find(val$query, val$fields, val$skip, val$batchSize);
    if (val$sort != null) {
      cur.sort(val$sort);
    }
    if (val$limit > 0) {
      cur.limit(val$limit);
    }
    if (val$hint != null) {
      cur.hint(val$hint);
    }
    if (val$explain) {
      return cur.explain();
    }
    return cur;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Find";
  }
  
  public Object getRoot(Object result)
  {
    if ((result == null) || (!(result instanceof DBCursor))) {
      return null;
    }
    return ((DBCursor)result).toString();
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import java.util.logging.Level;
import java.util.logging.Logger;

class CollectionPanel$7
  extends DbJob
{
  CollectionPanel$7(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, DBObject paramDBObject1, DBObject paramDBObject2, int paramInt1, int paramInt2, DBObject paramDBObject3, int paramInt3, DocumentSerializer paramDocumentSerializer, boolean paramBoolean) {}
  
  public Object doRun()
    throws Exception
  {
    try
    {
      try
      {
        DBCursor cur = val$col.find(val$query, val$fields);
        if (val$skip > 0) {
          cur.skip(val$skip);
        }
        if (val$batchSize != 0) {
          cur.batchSize(val$batchSize);
        }
        if (val$sort != null) {
          cur.sort(val$sort);
        }
        if (val$limit > 0) {
          cur.limit(val$limit);
        }
        while ((cur.hasNext()) && (!stopped)) {
          val$ds.writeObject(cur.next());
        }
      }
      catch (Exception e)
      {
        if (val$continueOnError) {
          getLogger().log(Level.WARNING, null, e);
        } else {
          throw e;
        }
      }
    }
    finally
    {
      val$ds.close();
    }
    return null;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Export";
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.7
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.mongodb.DBCollection;
import com.mongodb.DBObject;

final class CollectionPanel$8
  extends DbJob
{
  CollectionPanel$8(DBCollection paramDBCollection, DBObject paramDBObject1, DBObject paramDBObject2) {}
  
  public Object doRun()
  {
    return val$col.findOne(val$query, val$fields);
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "FindOne";
  }
  
  public Object getRoot(Object result)
  {
    return "query=" + val$query + ", fields=" + val$fields;
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.8
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.mongodb.DBCollection;

class CollectionPanel$9
  extends DbJob
{
  CollectionPanel$9(CollectionPanel paramCollectionPanel, DBCollection paramDBCollection, CollectionNode paramCollectionNode) {}
  
  public Object doRun()
  {
    val$col.drop();
    return null;
  }
  
  public String getNS()
  {
    return val$col.getFullName();
  }
  
  public String getShortName()
  {
    return "Drop";
  }
  
  public void wrapUp(Object res)
  {
    super.wrapUp(res);
    val$colNode.removeNode();
  }
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.9
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

 enum CollectionPanel$Item
{
  icon,  name,  fullName,  queryOptions,  writeConcern,  readPreference,  stats,  statsCmd,  refresh,  dropCollection,  rename,  newName,  dropTarget,  doImport,  export,  find,  findQuery,  findFields,  findSort,  findSkip,  findLimit,  findBatchSize,  findExplain,  findExport,  findHint,  findOne,  foQuery,  foFields,  count,  countQuery,  countSkip,  countLimit,  remove,  removeQuery,  rmAllConfirm,  mapReduce,  mrMap,  mrReduce,  mrFinalize,  mrQuery,  mrSort,  mrType,  mrOut,  mrOutDB,  mrOutSharded,  mrNonAtomic,  mrLimit,  mrJSMode,  group,  grpKeys,  grpQuery,  grpInitialValue,  grpReduce,  grpFinalize,  options,  insert,  insertDoc,  insertCount,  insertBulk,  ensureIndex,  eiKeys,  eiUnique,  eiName,  eiDropDups,  eiSparse,  eiExpireAfter,  eiBackground,  findAndModify,  famQuery,  famFields,  famSort,  famUpdate,  famRemove,  famReturnNew,  famUpsert,  update,  upQuery,  upUpdate,  upUpsert,  upMulti,  upSafe,  save,  saveDoc,  shardingInfo,  shardCollection,  shardKeyCombo,  shardCustomKey,  shardUniqueIndex,  findChunks,  validate,  validateFull,  touch,  touchData,  touchIndex,  compact,  compactForce,  reIndex,  moveChunk,  mvckQuery,  mvckToShard,  splitChunk,  spckQuery,  spckOnValue,  geoNear,  gnOrigin,  gnNum,  gnMaxDistance,  gnDistanceMultiplier,  gnQuery,  gnSpherical,  gnSearch,  lazyDecoding,  fixCollection,  fcDialog,  fcSrcMongo,  fcUpsert;
  
  private CollectionPanel$Item() {}
}

/* Location:
 * Qualified Name:     com.edgytech.umongo.CollectionPanel.Item
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.edgytech.umongo;

import com.edgytech.swingfast.ButtonBase;
import com.edgytech.swingfast.ComboBox;
import com.edgytech.swingfast.ConfirmDialog;
import com.edgytech.swingfast.EnumListener;
import com.edgytech.swingfast.FormDialog;
import com.edgytech.swingfast.InfoDialog;
import com.edgytech.swingfast.MenuItem;
import com.edgytech.swingfast.TreeNodeLabel;
import com.edgytech.swingfast.XmlComponentUnit;
import com.mongodb.BasicDBList;
import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.GroupCommand;
import com.mongodb.LazyDBDecoder;
import com.mongodb.MapReduceCommand;
import com.mongodb.MapReduceCommand.OutputType;
import com.mongodb.MapReduceOutput;
import com.mongodb.Mongo;
import com.mongodb.MongoException.DuplicateKey;
import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;

public class CollectionPanel
  extends BasePanel
  implements EnumListener<Item>
{
  static enum Item
  {
    icon,  name,  fullName,  queryOptions,  writeConcern,  readPreference,  stats,  statsCmd,  refresh,  dropCollection,  rename,  newName,  dropTarget,  doImport,  export,  find,  findQuery,  findFields,  findSort,  findSkip,  findLimit,  findBatchSize,  findExplain,  findExport,  findHint,  findOne,  foQuery,  foFields,  count,  countQuery,  countSkip,  countLimit,  remove,  removeQuery,  rmAllConfirm,  mapReduce,  mrMap,  mrReduce,  mrFinalize,  mrQuery,  mrSort,  mrType,  mrOut,  mrOutDB,  mrOutSharded,  mrNonAtomic,  mrLimit,  mrJSMode,  group,  grpKeys,  grpQuery,  grpInitialValue,  grpReduce,  grpFinalize,  options,  insert,  insertDoc,  insertCount,  insertBulk,  ensureIndex,  eiKeys,  eiUnique,  eiName,  eiDropDups,  eiSparse,  eiExpireAfter,  eiBackground,  findAndModify,  famQuery,  famFields,  famSort,  famUpdate,  famRemove,  famReturnNew,  famUpsert,  update,  upQuery,  upUpdate,  upUpsert,  upMulti,  upSafe,  save,  saveDoc,  shardingInfo,  shardCollection,  shardKeyCombo,  shardCustomKey,  shardUniqueIndex,  findChunks,  validate,  validateFull,  touch,  touchData,  touchIndex,  compact,  compactForce,  reIndex,  moveChunk,  mvckQuery,  mvckToShard,  splitChunk,  spckQuery,  spckOnValue,  geoNear,  gnOrigin,  gnNum,  gnMaxDistance,  gnDistanceMultiplier,  gnQuery,  gnSpherical,  gnSearch,  lazyDecoding,  fixCollection,  fcDialog,  fcSrcMongo,  fcUpsert;
    
    private Item() {}
  }
  
  public CollectionPanel()
  {
    setEnumBinding(Item.values(), this);
  }
  
  public CollectionNode getCollectionNode()
  {
    return (CollectionNode)getNode();
  }
  
  protected void updateComponentCustom(JPanel old)
  {
    try
    {
      DBCollection collection = getCollectionNode().getCollection();
      setStringFieldValue(Item.name, collection.getName());
      setStringFieldValue(Item.fullName, collection.getFullName());
      setStringFieldValue(Item.queryOptions, MongoUtils.queryOptionsToString(collection.getOptions()));
      ((DocField)getBoundUnit(Item.writeConcern)).setDoc(collection.getWriteConcern().getCommand());
      ((DocField)getBoundUnit(Item.readPreference)).setDoc(collection.getReadPreference().toDBObject());
      ((CmdField)getBoundUnit(Item.stats)).updateFromCmd(collection);
    }
    catch (Exception e)
    {
      UMongo.instance.showError(getClass().getSimpleName() + " update", e);
    }
  }
  
  public void actionPerformed(Item enm, XmlComponentUnit unit, Object src)
  {
    if (enm == Item.lazyDecoding)
    {
      boolean lazy = getBooleanFieldValue(Item.lazyDecoding);
      DBCollection col = getCollectionNode().getCollection();
      if (lazy) {
        col.setDBDecoderFactory(LazyDBDecoder.FACTORY);
      } else {
        col.setDBDecoderFactory(null);
      }
    }
  }
  
  public void find(final ButtonBase button)
  {
    final DBCollection col = getCollectionNode().getCollection();
    final DBObject query = ((DocBuilderField)getBoundUnit(Item.findQuery)).getDBObject();
    final DBObject fields = ((DocBuilderField)getBoundUnit(Item.findFields)).getDBObject();
    final DBObject sort = ((DocBuilderField)getBoundUnit(Item.findSort)).getDBObject();
    final DBObject hint = ((DocBuilderField)getBoundUnit(Item.findHint)).getDBObject();
    final int skip = getIntFieldValue(Item.findSkip);
    final int limit = getIntFieldValue(Item.findLimit);
    final int batchSize = getIntFieldValue(Item.findBatchSize);
    final boolean explain = getBooleanFieldValue(Item.findExplain);
    boolean export = getBooleanFieldValue(Item.findExport);
    if (export) {
      exportToFile(col, query, fields, sort, skip, limit, batchSize);
    } else {
      new DbJob()
      {
        public Object doRun()
        {
          DBCursor cur = col.find(query, fields, skip, batchSize);
          if (sort != null) {
            cur.sort(sort);
          }
          if (limit > 0) {
            cur.limit(limit);
          }
          if (hint != null) {
            cur.hint(hint);
          }
          if (explain) {
            return cur.explain();
          }
          return cur;
        }
        
        public String getNS()
        {
          return col.getFullName();
        }
        
        public String getShortName()
        {
          return "Find";
        }
        
        public Object getRoot(Object result)
        {
          if ((result == null) || (!(result instanceof DBCursor))) {
            return null;
          }
          return ((DBCursor)result).toString();
        }
        
        public ButtonBase getButton()
        {
          return button;
        }
      }.addJob();
    }
  }
  
  public void findOne(final ButtonBase button)
  {
    final DBCollection col = getCollectionNode().getCollection();
    final DBObject query = ((DocBuilderField)getBoundUnit(Item.foQuery)).getDBObject();
    final DBObject fields = ((DocBuilderField)getBoundUnit(Item.foFields)).getDBObject();
    
    new DbJob()
    {
      public Object doRun()
      {
        return col.findOne(query, fields);
      }
      
      public String getNS()
      {
        return col.getFullName();
      }
      
      public String getShortName()
      {
        return "FindOne";
      }
      
      public Object getRoot(Object result)
      {
        return "query=" + query + ", fields=" + fields;
      }
      
      public ButtonBase getButton()
      {
        return button;
      }
    }.addJob();
  }
  
  public void rename(ButtonBase button)
  {
    final CollectionNode colNode = getCollectionNode();
    final DBCollection col = colNode.getCollection();
    
    UMongo.instance.displayNode(colNode.getDbNode());
    
    final String name = getStringFieldValue(Item.newName);
    final boolean dropTarget = getBooleanFieldValue(Item.dropTarget
1 2 3 4 5 6 7 8

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd