Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge V8.2 branch #34

Merged
merged 25 commits into from
Jul 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
65f1890
update version
le-yams Jun 25, 2015
1081747
update lombok version
le-yams Jun 26, 2015
31e5c43
fix #26
le-yams Jun 26, 2015
5cf6a9d
updating mongo driver dependency version
le-yams Jun 26, 2015
84a99a4
start migrating
le-yams Jun 26, 2015
4163d08
improve collections sort
le-yams Jun 26, 2015
e149cdf
import #28 fix from 8.1.1
le-yams Jun 29, 2015
f37352c
updating mongo driver dependency version
le-yams Jun 26, 2015
e58c572
start migrating
le-yams Jun 26, 2015
b65b546
improve collections sort
le-yams Jun 26, 2015
d3c38f3
Merge branch 'migrate-mongodriver-v3' of https://github.com/le-yams/n…
le-yams Jun 29, 2015
148ad83
removing DB/DBCollection/DBObject references
le-yams Jun 29, 2015
46c8cc6
fix json validation (json parse exception has changed)
le-yams Jun 29, 2015
02debf5
small renaming
le-yams Jun 30, 2015
2e458dc
Merge pull request #29 from le-yams/migrate-mongodriver-v3
le-yams Jun 30, 2015
f559ec7
refactor dbs/collections stats as properties
le-yams Jun 30, 2015
0313d0d
Merge pull request #30 from le-yams/stats-as-properties
le-yams Jun 30, 2015
52703c8
some clean up
le-yams Jun 30, 2015
d4d4218
closes #16
le-yams Jun 30, 2015
dac14e3
fixes #31
le-yams Jun 30, 2015
41d8bf4
indexes management (see #32)
le-yams Jun 30, 2015
6cc3fa7
indexes management (see #32)
le-yams Jun 30, 2015
59fe4aa
fix #33
le-yams Jul 1, 2015
b73a70e
improving indexes management (see #32)
le-yams Jul 1, 2015
1cd26d4
Merge branch 'v8.2' of https://github.com/le-yams/netbeans-mongodb in…
le-yams Jul 1, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.netbeans.modules</groupId>
<artifactId>nbmongo</artifactId>
<version>8.1.0</version>
<version>8.2.0-SNAPSHOT</version>
<packaging>nbm</packaging>

<name>NBMongo</name>
Expand Down Expand Up @@ -160,16 +160,21 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.13.0</version>
<version>3.0.2</version>
<type>jar</type>
</dependency>


<!-- ##### Other Dependencies ##### -->
<dependency>
<groupId>com.github.jsonj</groupId>
<artifactId>jsonj</artifactId>
<version>0.8</version>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.cedarsoftware</groupId>
<artifactId>json-io</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>com.mytdev</groupId>
Expand All @@ -184,7 +189,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
<version>1.16.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/org/netbeans/modules/mongodb/CollectionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Objects;
import lombok.Getter;
import lombok.NonNull;
import org.netbeans.modules.mongodb.util.SystemCollectionPredicate;
import org.openide.util.Lookup;

/**
Expand All @@ -46,6 +47,10 @@ public CollectionInfo(@NonNull String name, @NonNull Lookup lookup) {
this.lookup = lookup;
}

public boolean isSystemCollection() {
return SystemCollectionPredicate.get().eval(name);
}

@Override
public boolean equals(Object object) {
if (object == null) {
Expand Down Expand Up @@ -79,6 +84,18 @@ public String toString() {

@Override
public int compareTo(CollectionInfo o) {
return name.compareToIgnoreCase(o.name);
int sysCol = isSystemCollection() ? 1 : 0;
sysCol |= o.isSystemCollection() ? 2 : 0;
switch (sysCol) {
case 1:
return -1;
case 2:
return 1;
case 0: // FALL THROUGH
case 3:
return name.compareToIgnoreCase(o.name);
default:
throw new AssertionError();
}
}
}
92 changes: 0 additions & 92 deletions src/main/java/org/netbeans/modules/mongodb/CollectionStats.java

This file was deleted.

95 changes: 0 additions & 95 deletions src/main/java/org/netbeans/modules/mongodb/DatabaseStats.java

This file was deleted.

13 changes: 7 additions & 6 deletions src/main/java/org/netbeans/modules/mongodb/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.netbeans.modules.mongodb;

import com.mongodb.DBObject;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
Expand All @@ -29,6 +28,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.bson.Document;

/**
* POJO that contains the data of an index.
Expand Down Expand Up @@ -87,12 +87,13 @@ public void propertyChange(PropertyChangeEvent evt) {
}
};

public Index(DBObject indexInfo) {
name = (String) indexInfo.get("name");
nameSpace = (String) indexInfo.get("ns");
final DBObject keyObj = (DBObject)indexInfo.get("key");
for(String keyObjProperty: keyObj.keySet())
public Index(Document indexInfo) {
name = indexInfo.getString("name");
nameSpace = indexInfo.getString("ns");
final Document keyObj = indexInfo.get("key", Document.class);
for(String keyObjProperty: keyObj.keySet()) {
keys.add(new Key(keyObjProperty, Integer.valueOf(1).equals(keyObj.get(keyObjProperty))));
}
sparse = Boolean.TRUE.equals(indexInfo.get("sparse"));
unique = Boolean.TRUE.equals(indexInfo.get("unique"));
dropDuplicates = Boolean.TRUE.equals(indexInfo.get("dropDups"));
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/netbeans/modules/mongodb/MongoConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.mongodb.MongoClient;
import com.mongodb.MongoException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
Expand Down Expand Up @@ -64,7 +63,7 @@ public void run() {
final ConnectionInfo connection = getLookup().lookup(ConnectionInfo.class);
try {
client = new MongoClient(connection.getMongoURI());
client.getDatabaseNames(); // ensure connection works
client.listDatabaseNames();
fireConnectionStateChanged(ConnectionState.CONNECTED);
} catch (MongoException ex) {
DialogDisplayer.getDefault().notify(
Expand All @@ -76,16 +75,6 @@ public void run() {
if (client != null) {
client.close();
}
} catch (UnknownHostException ex) {
DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
"unknown server: " + ex.getLocalizedMessage(),
NotifyDescriptor.ERROR_MESSAGE));
MongoClient client = MongoConnection.this.client;
MongoConnection.this.client = null;
if (client != null) {
client.close();
}
}
}
}, Bundle.waitWhileConnecting());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
*/
package org.netbeans.modules.mongodb;

import com.mongodb.DBObject;
import com.mongodb.MongoException;
import com.mongodb.util.JSON;
import org.bson.Document;

/**
* Unwrapps a MongoException message.
Expand All @@ -34,10 +33,10 @@ public MongoExceptionUnwrapper(Exception ex) {
if(ex instanceof MongoException) {
String msgValue = ex.getMessage();
try {
DBObject jsonMsg = (DBObject) JSON.parse(ex.getMessage());
msgValue = (String) jsonMsg.get("err");
Document document = Document.parse(ex.getMessage());
msgValue = document.getString("err");
if(msgValue == null || msgValue.isEmpty()) {
msgValue = (String) jsonMsg.get("errmsg");
msgValue = document.getString("errmsg");
}
} catch(Exception ignored) { }
message = msgValue;
Expand Down
Loading