Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
fixed some errors from the log
Browse files Browse the repository at this point in the history
  • Loading branch information
chicuslavic committed May 6, 2013
0 parents commit f2ed3cc
Show file tree
Hide file tree
Showing 49 changed files with 3,524 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .classpath
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>
28 changes: 28 additions & 0 deletions .project
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>
17 changes: 17 additions & 0 deletions .settings/com.wdev91.eclipse.copyright.xml
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>
7 changes: 7 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
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
14 changes: 14 additions & 0 deletions META-INF/MANIFEST.MF
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,
.
11 changes: 11 additions & 0 deletions build.properties
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/
14 changes: 14 additions & 0 deletions context.xml
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 &quot;classical&quot; 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>
14 changes: 14 additions & 0 deletions html/mongodb.html
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>
Binary file added icons/datasource.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/mongodb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/mongo-java-driver-2.7.3.jar
Binary file not shown.
35 changes: 35 additions & 0 deletions plugin.xml
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>
16 changes: 16 additions & 0 deletions pom.xml
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>
20 changes: 20 additions & 0 deletions resources/icons.properties
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

150 changes: 150 additions & 0 deletions src/com/jaspersoft/mongodb/MongoDbDataSource.java
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;
}
}
Loading

0 comments on commit f2ed3cc

Please sign in to comment.