Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ldoguin committed Jun 14, 2012
1 parent 30edbc5 commit 4f85142
Show file tree
Hide file tree
Showing 85 changed files with 4,003 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# common ignores
.classpath
.project
.settings
.idea
bin
target
*~
*~bak
*-bak
*.bak
*-new
*.rej
*.orig
.DS_Store
.pydevproject
*.pyc
*.iml
*.ipr
*.iws
*.gpd.*
*cpJar*
dependency-tree.log
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
nuxeo-geoloc
============

Add geographical localization to Nuxeo documents
Add geographical localization to Nuxeo documents. Every documents will have geo localization tab displaying a button to add the GeoLocalization facet. Once the facet is added it displays a map. User can point anywhere in the map and save the coordinates as doc properties.

There is also a 'Map' link in the user menu pointing to a map and displaying a pointer for every geolocalized document. When the user click on the pointer he gets a small popup with the doc title and a link to it.

TODO
====

Here are some ideas:
- show more information on the pointer popup (thumnail, desc...)
- use the cover metadata to filter pointers on the map
- add tags for pointers..
113 changes: 113 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.nuxeo.ecm.platform</groupId>
<artifactId>nuxeo-features-parent</artifactId>
<version>5.6-SNAPSHOT</version>
</parent>
<groupId>org.nuxeo</groupId>
<artifactId>nuxeo-geoloc</artifactId>
<name>nuxeo-geoloc</name>
<description/>
<dependencies>
<dependency>
<groupId>org.nuxeo.common</groupId>
<artifactId>nuxeo-common</artifactId>
</dependency>
<dependency>
<groupId>org.nuxeo.runtime</groupId>
<artifactId>nuxeo-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core</artifactId>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-api</artifactId>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-query</artifactId>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-schema</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi-core</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.platform</groupId>
<artifactId>nuxeo-platform-ui-web</artifactId>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.platform</groupId>
<artifactId>nuxeo-platform-webapp-base</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<additionalProjectnatures>
<projectnature>org.nuxeo.ide.NuxeoNature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>org.nuxeo.ide.SDK_CONTAINER</classpathContainer>
<classpathContainer>org.nuxeo.ide.SDK_TEST_CONTAINER</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/seam</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
46 changes: 46 additions & 0 deletions src/main/java/org/nuxeo/geolocalization/GeoLocalization.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2007-2012 Nuxeo SA (http://nuxeo.com/) and others.
*
* All rights reserved. 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:
* ldoguin
*
*/
package org.nuxeo.geolocalization;

import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.model.Property;

/**
* @author ldoguin
*/
public class GeoLocalization {

protected final DocumentModel doc;

public GeoLocalization(DocumentModel doc) {
this.doc = doc;
}

public String getLatitude() {
return getStringPropertyValue(GeoLocalizationConstant.LOCALIZATION_LATITUDE_PROPERTY_NAME);
}

public String getLongitude() {
return getStringPropertyValue(GeoLocalizationConstant.LOCALIZATION_LONGITUDE_PROPERTY_NAME);
}

protected String getStringPropertyValue(String xPath) {
try {
Property p = doc.getProperty(xPath);
return p.getValue(String.class);
} catch (ClientException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2007-2012 Nuxeo SA (http://nuxeo.com/) and others.
*
* All rights reserved. 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:
* ldoguin
*
*/
package org.nuxeo.geolocalization;

public class GeoLocalizationConstant {

public static final String LOCALIZATION_FACET_NAME = "GeoLocalization";

public static final String LOCALIZATION_LATITUDE_PROPERTY_NAME = "geolocalization:latitude";

public static final String LOCALIZATION_LONGITUDE_PROPERTY_NAME = "geolocalization:longitude";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2007-2012 Nuxeo SA (http://nuxeo.com/) and others.
*
* All rights reserved. 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:
* ldoguin
*
*/
package org.nuxeo.geolocalization;

import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.adapter.DocumentAdapterFactory;

/**
* @author ldoguin
*/
public class GeoLocalizationFactory implements DocumentAdapterFactory {

@Override
public Object getAdapter(DocumentModel doc, Class<?> itf) {
return new GeoLocalization(doc);
}

}
14 changes: 14 additions & 0 deletions src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-Vendor: Nuxeo
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Version: 5.6-I20120602_0116
Bundle-Name: nuxeo-localization
Bundle-ManifestVersion: 2
Nuxeo-Component: OSGI-INF/core-types-contrib.xml,OSGI-INF/theme-contri
b.xml,OSGI-INF/actions-contrib.xml,OSGI-INF/extensions/org.nuxeo.geol
ocalization.GeoLocalization.xml,OSGI-INF/extensions/org.nuxeo.geoloca
lization.geolocalizationManagerBean.xml
Bundle-SymbolicName: nuxeo-localization
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

12 changes: 12 additions & 0 deletions src/main/resources/OSGI-INF/actions-contrib.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="org.nuxeo.geolocalization.actions">

<extension target="org.nuxeo.ecm.platform.actions.ActionService"
point="actions">

<action id="document_map" link="#{geoLocalizationManager.goToMap()}"
label="command.map" order="10">
<category>USER_MENU_ACTIONS</category>
</action>
</extension>

</component>
16 changes: 16 additions & 0 deletions src/main/resources/OSGI-INF/core-types-contrib.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>

<component name="org.nuxeo.geolocalization.core.type.contrib">

<require>org.nuxeo.ecm.core.CoreExtensions</require>

<extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
<schema name="geolocalization" src="schemas/geolocalization.xsd" prefix="thumb" />
</extension>

<extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
<facet name="GeoLocalization">
<schema name="geolocalization" />
</facet>
</extension>
</component>
38 changes: 38 additions & 0 deletions src/main/resources/OSGI-INF/deployment-fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>

<fragment version="1">

<require>org.nuxeo.ecm.platform.lang</require>
<require>org.nuxeo.ecm.webapp.core</require>

<install>
<unzip from="${bundle.fileName}" to="/" prefix="web">
<include>web/nuxeo.war/**</include>
</unzip>

<delete path="${bundle.fileName}.tmp"/>
<unzip from="${bundle.fileName}" to="${bundle.fileName}.tmp" prefix="OSGI-INF/l10n">
<include>OSGI-INF/l10n/*-messages.properties</include>
</unzip>
<append from="${bundle.fileName}.tmp" pattern="*-messages.properties" to="nuxeo.war/WEB-INF/classes/messages.properties" addNewLine="true"/>
<delete path="${bundle.fileName}.tmp"/>
</install>



<extension target="pages#PAGES">
<page view-id="/map.xhtml" >
breadcrumb=command.map
</page>
</extension>

<extension target="faces-config#NAVIGATION">
<!-- Map of geolocalized documents -->
<navigation-case>
<from-outcome>geo_localization_map</from-outcome>
<to-view-id>/map.xhtml</to-view-id>
<redirect />
</navigation-case>
</extension>

</fragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<component name="org.nuxeo.geolocalization.GeoLocalization">

<extension target="org.nuxeo.ecm.core.api.DocumentAdapterService" point="adapters">
<adapter facet="GeoLocalization"
class="org.nuxeo.geolocalization.GeoLocalization"
factory="org.nuxeo.geolocalization.GeoLocalizationFactory"/>
</extension>

</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<component name="org.nuxeo.geolocalization.geoLocalizationManagerBean">

<extension target="org.nuxeo.ecm.platform.actions.ActionService"
point="actions">

<action id="org.nuxeo.geolocalization.geolocalizationManagerBean" link="/incl/tabs/org.nuxeo.geolocalization.geolocalizationManagerBean-tab.xhtml"
label="label.org.nuxeo.geolocalization.geolocalizationManagerBean"
icon="/icons/org.nuxeo.geolocalization.geolocalizationManagerBean-tab.gif" order="200">
<category>VIEW_ACTION_LIST</category>
</action>
</extension>

</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
label.org.nuxeo.geolocalization.geolocalizationManagerBean=Geo Localization
command.map=Map
command.geolocalization.add=Add geographical localization
label.geolocalization.latitude=Latitude:
label.geolocalization.longitude=Longitude:
command.geolocalization.update=Update coordinates
17 changes: 17 additions & 0 deletions src/main/resources/OSGI-INF/theme-contrib.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<component name="org.nuxeo.geolocalization.theme.contrib">

<extension target="org.nuxeo.theme.styling.service" point="resources">
<resource name="openlayer.js">
<path>scripts/openlayers/OpenLayers.js</path>
</resource>
</extension>
<extension target="org.nuxeo.theme.styling.service" point="pages">
<themePage name="galaxy/default">
<resources append="true">
<resource>openlayer.js</resource>
</resources>
</themePage>
</extension>

</component>
8 changes: 8 additions & 0 deletions src/main/resources/schemas/geolocalization.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:nxs="http://www.nuxeo.org/ecm/schemas/geolocalization" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.nuxeo.org/ecm/schemas/geolocalization">

<xs:element name="latitude" type="xs:string"/>
<xs:element name="longitude" type="xs:string"/>

</xs:schema>
Loading

0 comments on commit 4f85142

Please sign in to comment.