This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://code.jaspersoft.com/svn/repos/jaspersoftstudio/trunk/com.jaspersoft.studio.data.mongodb@2702 6833c83e-4fd0-4c68-a3df-283c6148db30
- Loading branch information
chicuslavic
committed
May 6, 2013
0 parents
commit f2ed3cc
Showing
49 changed files
with
3,524 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry exported="true" kind="lib" path="lib/mongo-java-driver-2.7.3.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>com.jaspersoft.studio.data.mongodb</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<project> | ||
<owner></owner> | ||
<copyright><![CDATA[Copyright (C) 2010 - ${year} Jaspersoft Corporation. All rights reserved. | ||
http://www.jaspersoft.com | ||
Unless you have purchased a commercial license agreement from Jaspersoft, | ||
the following license terms apply: | ||
This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Jaspersoft Studio Team - initial API and implementation]]></copyright> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: MongoDB Plugin | ||
Bundle-SymbolicName: com.jaspersoft.studio.data.mongodb;singleton:=true | ||
Bundle-Version: 5.1.1.qualifier | ||
Bundle-Activator: com.jaspersoft.studio.data.mongodb.Activator | ||
Bundle-Vendor: Jaspersoft Corporation | ||
Require-Bundle: com.jaspersoft.studio.data;bundle-version="5.1.1";visibility:=reexport, | ||
com.jaspersoft.studio.server;bundle-version="5.1.1" | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 | ||
Bundle-ActivationPolicy: lazy | ||
Eclipse-RegisterBuddy: com.jaspersoft.studio.data | ||
Bundle-ClassPath: lib/mongo-java-driver-2.7.3.jar, | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
plugin.xml,\ | ||
icons/,\ | ||
lib/mongo-java-driver-2.7.3.jar,\ | ||
src/,\ | ||
resources/,\ | ||
toc_dataadapters.xml,\ | ||
html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<contexts> | ||
|
||
|
||
<context id="adapter_mongodb" title="MongoDB Data Adapter"> | ||
<description>MongoDB is an open source document-oriented database system developed and supported by 10gen. It is part of the NoSQL family of database systems. Instead of storing data in tables as is done in a "classical" relational database, MongoDB stores structured data as JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster.</description> | ||
<topic href="html/mongodb.html" label="MongoDB Data Adapter"/> | ||
</context> | ||
<context id="query_mongo" title="Dataset and query dialog"> | ||
<description>From this dialog you can change the dataset query, define new parameters or change the adapter used to retrive the data.</description> | ||
<topic href="http://docs.mongodb.org/manual/" label="The MongoDB Manual"/> | ||
<topic href="http://docs.mongodb.org/manual/core/read-operations/" label="Read Operations Reference"/> | ||
</context> | ||
</contexts> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
<body> | ||
MongoDB is an open source document-oriented database system developed | ||
and supported by 10gen. It is part of the NoSQL family of database | ||
systems. Instead of storing data in tables as is done in a "classical" | ||
relational database, MongoDB stores structured data as JSON-like | ||
documents with dynamic schemas (MongoDB calls the format BSON), making | ||
the integration of data in certain types of applications easier and | ||
faster. | ||
<br> | ||
<a href="http://www.mongodb.org/">website</a> | ||
|
||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="com.jaspersoft.studio.dataAdapters"> | ||
<dataAdapter ClassFactory="com.jaspersoft.studio.data.mongodb.MongoDbDataAdapterFactory"/> | ||
</extension> | ||
<extension | ||
point="com.jaspersoft.studio.queryDesigner"> | ||
<queryDesigner | ||
QueryDesignerClass="com.jaspersoft.studio.data.mongodb.querydesigner.MongoDBQueryDesigner" | ||
language="MongoDbQuery"> | ||
</queryDesigner> | ||
</extension> | ||
<extension | ||
point="com.jaspersoft.studio.server.resources"> | ||
<resource | ||
ClassFactory="com.jaspersoft.studio.data.mongodb.server.MongoResourceFactory"> | ||
</resource> | ||
</extension> | ||
<extension | ||
point="org.eclipse.help.toc"> | ||
<toc | ||
file="toc_dataadapters.xml" | ||
primary="false"> | ||
</toc> | ||
</extension> | ||
<extension | ||
point="org.eclipse.help.contexts"> | ||
<contexts | ||
file="context.xml" | ||
plugin="com.jaspersoft.studio.doc"> | ||
</contexts> | ||
</extension> | ||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.jaspersoft.studio.community-edition</groupId> | ||
<artifactId>plugins</artifactId> | ||
<version>5.1.1-SNAPSHOT</version> | ||
<relativePath>../aggregator/plugins/</relativePath> | ||
</parent> | ||
|
||
<groupId>com.jaspersoft.studio.community-edition</groupId> | ||
<artifactId>com.jaspersoft.studio.data.mongodb</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
<version>5.1.1-SNAPSHOT</version> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#------------------------------------------------------------------------------- | ||
# Copyright (C) 2010 - 2013 Jaspersoft Corporation. All rights reserved. | ||
# http://www.jaspersoft.com | ||
# | ||
# Unless you have purchased a commercial license agreement from Jaspersoft, | ||
# the following license terms apply: | ||
# | ||
# This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
# Contributors: | ||
# Jaspersoft Studio Team - initial API and implementation | ||
#------------------------------------------------------------------------------- | ||
datasource-mongo.title=MongoDB Datasource | ||
datasource-mongo.description=MongoDB Datasource | ||
datasource-mongo.icon16=icons/mongodb.png | ||
datasource-mongo.icon32=icons/mongodb.png | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2010 - 2013 Jaspersoft Corporation. All rights reserved. | ||
* http://www.jaspersoft.com | ||
* | ||
* Unless you have purchased a commercial license agreement from Jaspersoft, | ||
* the following license terms apply: | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Jaspersoft Studio Team - initial API and implementation | ||
******************************************************************************/ | ||
package com.jaspersoft.mongodb; | ||
|
||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import net.sf.jasperreports.engine.JRDataSource; | ||
import net.sf.jasperreports.engine.JRException; | ||
import net.sf.jasperreports.engine.JRField; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.jaspersoft.mongodb.query.MongoDbQueryWrapper; | ||
import com.mongodb.DBObject; | ||
|
||
/** | ||
* An implementation of a data source that uses an empty query and parameters | ||
* | ||
* @author Eric Diaz | ||
* | ||
*/ | ||
public class MongoDbDataSource implements JRDataSource { | ||
private MongoDbQueryWrapper wrapper; | ||
|
||
private DBObject currentDbObject; | ||
|
||
public static final String QUERY_LANGUAGE = "MongoDbQuery"; | ||
|
||
private static final Logger logger = Logger.getLogger(MongoDbDataSource.class); | ||
|
||
private boolean hasIterator = false; | ||
|
||
private boolean hasCommandResult = false; | ||
|
||
private Iterator<?> resultsIterator; | ||
|
||
private Map<?, ?> currentResult; | ||
|
||
public MongoDbDataSource(MongoDbQueryWrapper wrapper) { | ||
logger.info("New MongoDB Data Source"); | ||
this.wrapper = wrapper; | ||
hasIterator = wrapper.iterator != null; | ||
if (!hasIterator) { | ||
hasCommandResult = wrapper.commandResults != null; | ||
resultsIterator = wrapper.commandResults.iterator(); | ||
} | ||
} | ||
|
||
/** | ||
* Gets the field value for the current position. | ||
*/ | ||
@Override | ||
public Object getFieldValue(JRField field) throws JRException { | ||
try { | ||
if (field.getName() == null) { | ||
return null; | ||
} | ||
String[] ids = field.getName().split("\\" + MongoDbFieldsProvider.FIELD_NAME_SEPARATOR); | ||
if (hasIterator) { | ||
return getCursorValue(ids); | ||
} else if (hasCommandResult) { | ||
return getCommandResult(ids); | ||
} | ||
return null; | ||
} catch (Exception e) { | ||
logger.error(e); | ||
throw new JRException(e.getMessage()); | ||
} | ||
} | ||
|
||
private Object getCommandResult(String[] ids) { | ||
Map<?, ?> currentMap = currentResult; | ||
for (int index = 0; index < ids.length; index++) { | ||
boolean isLast = index == (ids.length - 1); | ||
String id = ids[index]; | ||
Object currentFieldObject = currentMap.get(id); | ||
if (currentFieldObject == null) { | ||
return null; | ||
} | ||
if (currentFieldObject instanceof Map) { | ||
if (isLast) { | ||
return currentFieldObject; | ||
} | ||
currentMap = (Map<?, ?>) currentFieldObject; | ||
} else { | ||
if (isLast) { | ||
return currentFieldObject; | ||
} | ||
return null; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private Object getCursorValue(String[] ids) { | ||
DBObject fieldObject = currentDbObject; | ||
for (int index = 0; index < ids.length; index++) { | ||
boolean isLast = index == (ids.length - 1); | ||
String id = ids[index]; | ||
Object currentFieldObject = fieldObject.get(id); | ||
if (currentFieldObject == null) { | ||
return null; | ||
} | ||
if (currentFieldObject instanceof DBObject) { | ||
if (isLast) { | ||
return currentFieldObject; | ||
} | ||
fieldObject = (DBObject) currentFieldObject; | ||
} else { | ||
if (isLast) { | ||
return currentFieldObject; | ||
} | ||
return null; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Tries to position the cursor on the next element in the data source. | ||
*/ | ||
@Override | ||
public boolean next() throws JRException { | ||
boolean next = false; | ||
if (hasIterator && (next = wrapper.iterator.hasNext())) { | ||
currentDbObject = wrapper.iterator.next(); | ||
} else if (hasCommandResult) { | ||
next = resultsIterator.hasNext(); | ||
currentResult = null; | ||
if (next) { | ||
currentResult = (Map<?, ?>) resultsIterator.next(); | ||
} | ||
} | ||
return next; | ||
} | ||
} |
Oops, something went wrong.