Revision 38508

View differences:

tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/README.txt
1
The first time you checkout the current project to a new workspace, 
2
you have to prepare it to be able to work easily with maven from
3
eclipse itself.
4

  
5
Perform the following steps:
6

  
7
1.- Launch the *prepare-workspace.xml* ant build file. 
8
    You can do it by loading the file into the ant view, 
9
    and running the default task, or right-clicking the 
10
    file from the package explorer or the navigator and
11
    select the option: *Run as > Ant build*. 
12
    
13
2.- Restart eclipse.
14

  
15
3.- Import the subprojects of the project you have just checked out.
16

  
17
Those steps are only needed once per workspace.     
18

  
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.personaldb.main</artifactId>
6
    <packaging>jar</packaging>
7
    <name>org.gvsig.personaldb.main</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.personaldb</artifactId>
11
        <version>1.0.0-SNAPSHOT</version>
12
    </parent>
13
    <dependencies>
14
        <dependency>
15
            <groupId>org.gvsig</groupId>
16
            <artifactId>org.gvsig.personaldb.lib.api</artifactId>
17
            <version>1.0.0-SNAPSHOT</version>
18
            <scope>compile</scope>
19
        </dependency>
20
        <dependency>
21
            <groupId>org.gvsig</groupId>
22
            <artifactId>org.gvsig.personaldb.lib.impl</artifactId>
23
            <version>1.0.0-SNAPSHOT</version>
24
            <scope>runtime</scope>
25
        </dependency>
26
        <dependency>
27
            <groupId>org.gvsig</groupId>
28
            <artifactId>org.gvsig.tools.lib</artifactId>
29
            <scope>compile</scope>
30
        </dependency>        
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.core.maven.dependencies</artifactId>
34
            <version>2.0.1-SNAPSHOT</version>
35
            <type>pom</type>
36
            <scope>runtime</scope>
37
        </dependency>
38
        <dependency>
39
            <groupId>org.slf4j</groupId>
40
            <artifactId>slf4j-api</artifactId>
41
            <scope>compile</scope>
42
        </dependency>
43
    </dependencies>
44
    <build>
45
        <plugins>
46
            <plugin>
47
                <groupId>org.codehaus.mojo</groupId>
48
                <artifactId>exec-maven-plugin</artifactId>
49
                <executions>
50
                    <execution>
51
                        <goals>
52
                            <goal>exec</goal>
53
                        </goals>
54
                    </execution>
55
                </executions>
56
                <configuration>
57
                    <executable>java</executable>
58
                    <arguments>
59
                        <argument>-classpath</argument>
60
                        <!-- automatically creates the classpath using all project 
61
                            dependencies, also adding the project build directory -->
62
                        <classpath />
63
                        <argument>org.gvsig.personaldb.main.Main</argument>
64
                    </arguments>
65
                    <environmentVariables>
66
                    </environmentVariables>
67
                </configuration>
68
            </plugin>
69
        </plugins>
70
    </build>
71
</project>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.personaldb">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/resources/README.txt
1
Put into this folder the resources needed by your classes.
2

  
3
This folder is added to the classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your classes.
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/java/org/gvsig/personaldb/main/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.personaldb package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>PersonalDB library testing and demo application.</p>
11

  
12
</body>
13
</html>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/java/org/gvsig/personaldb/main/Main.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
package org.gvsig.personaldb.main;
24

  
25
import java.sql.Connection;
26
import java.sql.DatabaseMetaData;
27
import java.sql.SQLException;
28

  
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

  
32
import org.gvsig.personaldb.PersonalDBException;
33
import org.gvsig.personaldb.PersonalDBLocator;
34
import org.gvsig.personaldb.PersonalDBManager;
35
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
36

  
37
/**
38
 * Main executable class for testing the PersonalDB library.
39
 * 
40
 * @author gvSIG Team
41
 * @version $Id$
42
 */
43
public class Main {
44

  
45
    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
46

  
47
    public static void main(String args[]) {
48
        Main main = new Main();
49
        try {
50
            main.show();
51
        } catch (Throwable e) {
52
            e.printStackTrace();
53
            System.exit(-1);
54
        }
55
        System.exit(0);
56
    }
57

  
58
    public void show() throws PersonalDBException, SQLException {
59

  
60
        new DefaultLibrariesInitializer().fullInitialize();
61
        PersonalDBManager manager = PersonalDBLocator.getManager();
62

  
63
        Connection connection = manager.getConnection();
64
        DatabaseMetaData metadata = connection.getMetaData();
65
        LOG.info("DatabaseMetadata: {}", metadata);
66
    }
67

  
68
}
0 69

  
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.personaldb.PersonalDBLibrary
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/PersonalDBLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb;
23

  
24
import org.gvsig.tools.locator.BaseLocator;
25
import org.gvsig.tools.locator.Locator;
26
import org.gvsig.tools.locator.LocatorException;
27

  
28
/**
29
 * This locator is the entry point for the PersonalDB library, providing
30
 * access to all PersonalDB services through the {@link PersonalDBManager}
31
 * .
32
 * 
33
 * @author gvSIG team
34
 * @version $Id$
35
 */
36
public class PersonalDBLocator extends BaseLocator {
37

  
38
    /**
39
     * PersonalDB manager name.
40
     */
41
    public static final String MANAGER_NAME = "PersonalDB.manager";
42

  
43
    /**
44
     * PersonalDB manager description.
45
     */
46
    public static final String MANAGER_DESCRIPTION = "PersonalDB Manager";
47

  
48
    private static final String LOCATOR_NAME = "PersonalDB.locator";
49

  
50
    /**
51
     * Unique instance.
52
     */
53
    private static final PersonalDBLocator INSTANCE =
54
        new PersonalDBLocator();
55

  
56
    /**
57
     * Return the singleton instance.
58
     * 
59
     * @return the singleton instance
60
     */
61
    public static PersonalDBLocator getInstance() {
62
        return INSTANCE;
63
    }
64

  
65
    /**
66
     * Return the Locator's name.
67
     * 
68
     * @return a String with the Locator's name
69
     */
70
    public final String getLocatorName() {
71
        return LOCATOR_NAME;
72
    }
73

  
74
    /**
75
     * Return a reference to the PersonalDBManager.
76
     * 
77
     * @return a reference to the PersonalDBManager
78
     * @throws LocatorException
79
     *             if there is no access to the class or the class cannot be
80
     *             instantiated
81
     * @see Locator#get(String)
82
     */
83
    public static PersonalDBManager getManager() throws LocatorException {
84
        return (PersonalDBManager) getInstance().get(MANAGER_NAME);
85
    }
86

  
87
    /**
88
     * Registers the Class implementing the PersonalDBManager interface.
89
     * 
90
     * @param clazz
91
     *            implementing the PersonalDBManager interface
92
     */
93
    public static void registerManager(
94
        Class<? extends PersonalDBManager> clazz) {
95
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
96
    }
97

  
98
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/PersonalDBLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb;
23

  
24
import org.gvsig.tools.library.AbstractLibrary;
25
import org.gvsig.tools.library.LibraryException;
26
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
27

  
28
/**
29
 * Library for PersonalDB API initialization and configuration.
30
 * 
31
 * @author gvSIG team
32
 * @version $Id$
33
 */
34
public class PersonalDBLibrary extends AbstractLibrary {
35

  
36
    @Override
37
    public void doRegistration() {
38
        registerAsAPI(PersonalDBLibrary.class);
39
    }
40

  
41
    @Override
42
    protected void doInitialize() throws LibraryException {
43
        // Do nothing
44
    }
45

  
46
    @Override
47
    protected void doPostInitialize() throws LibraryException {
48
        // Validate there is any implementation registered.
49
        PersonalDBManager manager = PersonalDBLocator.getManager();
50
        if (manager == null) {
51
            throw new ReferenceNotRegisteredException(
52
                PersonalDBLocator.MANAGER_NAME, PersonalDBLocator
53
                    .getInstance());
54
        }
55
    }
56

  
57
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.personaldb package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>PersonalDB library API.</p>
11
	
12
	<p>
13
	It allows to get new PersonalDB and get their text.
14
	</p>
15

  
16
</body>
17
</html>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/DataServerExplorerParametersException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb;
23

  
24

  
25
/**
26
 * Exception thrown when there is an error creating a connection to the
27
 * personal database.
28
 * 
29
 * @author gvSIG Team
30
 * @version $Id$
31
 */
32
public class DataServerExplorerParametersException extends PersonalDBException {
33

  
34
    private static final long serialVersionUID = 8918999379397938916L;
35

  
36
    private final static String MESSAGE_FORMAT =
37
        "Error creating a DataServerExplorerParameters for the personal "
38
            + "database of the type: %(name)";
39
    private final static String MESSAGE_KEY =
40
        "_DataServerExplorerParametersException";
41

  
42
    /**
43
     * Constructor with a message and a cause
44
     */
45
    public DataServerExplorerParametersException(String name,
46
        Throwable cause) {
47
        super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
48
        setValue("name", name);
49
    }
50
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/PersonalDBManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb;
23

  
24
import java.sql.Connection;
25

  
26
import org.gvsig.fmap.dal.DataParameters;
27
import org.gvsig.fmap.dal.DataServerExplorerParameters;
28
import org.gvsig.fmap.dal.DataStoreParameters;
29

  
30
/**
31
 * This class is responsible of the management of the library's business logic.
32
 * It is the library's main entry point, and provides all the services to manage
33
 * {@link Connection}s and {@link DataParameters} to connect to the personal
34
 * database.
35
 * 
36
 * @see PersonalDBService
37
 * @author gvSIG team
38
 * @version $Id$
39
 */
40
public interface PersonalDBManager {
41

  
42
    /**
43
     * Returns a {@link Connection} the personal database.
44
     * 
45
     * @return a connection to the personal database
46
     * @throws PersonalDBException
47
     *             if there is an error getting the connection
48
     */
49
    public Connection getConnection() throws PersonalDBException;
50

  
51
    /**
52
     * Returns a {@link DataStoreParameters} to connect to the personal database
53
     * through the DAL library.
54
     * 
55
     * @return the DAL data store parameters to connect to connect to the
56
     *         database
57
     * @throws PersonalDBException
58
     *             if there is an error creating the parameters
59
     */
60
    public DataStoreParameters getDataStoreParameters()
61
        throws PersonalDBException;
62

  
63
    /**
64
     * Returns a {@link DataStoreParameters} to connect to the personal database
65
     * through the DAL library.
66
     * 
67
     * @param schema
68
     *            the schema of the table to load data from
69
     * @param table
70
     *            the name of the table to load data from
71
     * @return the DAL data store parameters to connect to connect to the
72
     *         database
73
     * @throws PersonalDBException
74
     *             if there is an error creating the parameters
75
     */
76
    public DataStoreParameters getDataStoreParameters(String schema,
77
        String table) throws PersonalDBException;
78

  
79
    /**
80
     * Returns a {@link DataServerExplorerParameters} to connect to the personal
81
     * database
82
     * through the DAL library.
83
     * 
84
     * @return the DAL data server explorer parameters to connect to connect to
85
     *         the
86
     *         database
87
     * @throws PersonalDBException
88
     *             if there is an error creating the parameters
89
     */
90
    public DataServerExplorerParameters getDataServerExplorerParameters()
91
        throws PersonalDBException;
92

  
93
    /**
94
     * Returns a {@link DataServerExplorerParameters} to connect to the personal
95
     * database
96
     * through the DAL library.
97
     * 
98
     * @param schema
99
     *            the schema of the database to connect to
100
     * @return the DAL data server explorer parameters to connect to connect to
101
     *         the
102
     *         database
103
     * @throws PersonalDBException
104
     *             if there is an error creating the parameters
105
     */
106
    public DataServerExplorerParameters getDataServerExplorerParameters(
107
        String schema) throws PersonalDBException;
108

  
109
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/DBAccessException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb;
23

  
24
import org.gvsig.fmap.dal.DataParameters;
25

  
26
/**
27
 * Exception thrown when there is an error creating a connection to the
28
 * personal database.
29
 * 
30
 * @author gvSIG Team
31
 * @version $Id$
32
 */
33
public class DBAccessException extends PersonalDBException {
34

  
35
    private static final long serialVersionUID = 8918999379397938916L;
36

  
37
    private final static String MESSAGE_FORMAT =
38
        "Access error to a database whose parameters are: %(parameters)";
39
    private final static String MESSAGE_KEY = "_DBAccessException";
40

  
41
    /**
42
     * Constructor with a message and a cause
43
     */
44
    public DBAccessException(DataParameters parameters, Throwable cause) {
45
        super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
46
        setValue("parameters", parameters.toString());
47
    }
48
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/PersonalDBException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb;
23

  
24
import org.gvsig.tools.exception.BaseException;
25

  
26
/**
27
 * Generic exception thrown in the PersonalDB API when the exception or error
28
 * may be dealt by the program or the user of the program which is a client of
29
 * the PersonalDB API.
30
 * 
31
 * @see {@link PersonalDBManager}
32
 * @author gvSIG team.
33
 * @version $Id$
34
 */
35
public class PersonalDBException extends BaseException {
36

  
37
    private static final long serialVersionUID = 6756475060924237176L;
38

  
39
    private static final String MESSAGE =
40
        "An error has been produced in the PersonalDB library";
41

  
42
    private static final String KEY = "_PersonalDBException";
43

  
44
    /**
45
     * Constructor to be used in rare cases, usually you must create a new child
46
     * exception class for each case.
47
     * <strong>Don't use this constructor in child classes.</strong>
48
     */
49
    public PersonalDBException() {
50
        super(MESSAGE, KEY, serialVersionUID);
51
    }
52

  
53
    /**
54
     * Constructor to be used in rare cases, usually you must create a new child
55
     * exception class for each case.
56
     * <p>
57
     * <strong>Don't use this constructor in child classes.</strong>
58
     * </p>
59
     * 
60
     * @param cause
61
     *            the original cause of the exception
62
     */
63
    public PersonalDBException(Exception cause) {
64
        super(MESSAGE, cause, KEY, serialVersionUID);
65
    }
66

  
67
    /**
68
     * @see BaseException#BaseException(String, String, long).
69
     * @param message
70
     *            the default messageFormat to describe the exception
71
     * @param key
72
     *            the key to use to search a localized messageFormnata
73
     * @param code
74
     *            the unique code to identify the exception
75
     */
76
    protected PersonalDBException(String message, String key, long code) {
77
        super(message, key, code);
78
    }
79

  
80
    /**
81
     * @see BaseException#BaseException(String, Throwable, String, long).
82
     * @param message
83
     *            the default messageFormat to describe the exception
84
     * @param cause
85
     *            the original cause of the exception
86
     * @param key
87
     *            the key to use to search a localized messageFormnata
88
     * @param code
89
     *            the unique code to identify the exception
90
     */
91
    protected PersonalDBException(String message, Throwable cause,
92
        String key, long code) {
93
        super(message, cause, key, code);
94
    }
95
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.personaldb.lib.api</artifactId>
6
    <packaging>jar</packaging>
7
    <name>org.gvsig.personaldb.lib.api</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.personaldb.lib</artifactId>
11
        <version>1.0.0-SNAPSHOT</version>
12
    </parent>
13
    <build>
14
        <plugins>
15
            <plugin>
16
                <groupId>org.apache.maven.plugins</groupId>
17
                <artifactId>maven-jar-plugin</artifactId>
18
                <configuration>
19
                </configuration>
20
                <executions>
21
                    <!-- Generates a jar file only with the test classes -->
22
                    <execution>
23
                        <goals>
24
                            <goal>test-jar</goal>
25
                        </goals>
26
                    </execution>
27
                </executions>
28
            </plugin>
29
        </plugins>
30
    </build>
31
    <dependencies>
32
        <dependency>
33
            <groupId>org.gvsig</groupId>
34
            <artifactId>org.gvsig.tools.lib</artifactId>
35
            <scope>compile</scope>
36
        </dependency>
37
        <dependency>
38
            <groupId>org.gvsig</groupId>
39
            <artifactId>org.gvsig.fmap.dal</artifactId>
40
            <scope>compile</scope>
41
        </dependency>
42
    </dependencies>
43
</project>
0 44

  
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4
		 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5

  
6
	<modelVersion>4.0.0</modelVersion>
7
	<artifactId>org.gvsig.personaldb.lib</artifactId>
8
	<packaging>pom</packaging>
9
	<name>org.gvsig.personaldb.lib</name>
10
	<parent>
11
		<groupId>org.gvsig</groupId>
12
		<artifactId>org.gvsig.personaldb</artifactId>
13
		<version>1.0.0-SNAPSHOT</version>
14
	</parent>
15

  
16
	<modules>
17
		<module>org.gvsig.personaldb.lib.api</module>
18
		<module>org.gvsig.personaldb.lib.impl</module>
19
	</modules>
20
</project>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.personaldb.impl.PersonalDBDefaultImplLibrary
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/main/java/org/gvsig/personaldb/impl/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.personaldb package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>PersonalDB library API default implementation.</p>
11

  
12
</body>
13
</html>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/main/java/org/gvsig/personaldb/impl/PersonalDBDefaultImplLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb.impl;
23

  
24
import org.gvsig.fmap.dal.store.jdbc.JDBCLibrary;
25
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
26
import org.gvsig.personaldb.PersonalDBLibrary;
27
import org.gvsig.personaldb.PersonalDBLocator;
28
import org.gvsig.tools.library.AbstractLibrary;
29
import org.gvsig.tools.library.LibraryException;
30

  
31
/**
32
 * Library for default implementation initialization and configuration.
33
 * 
34
 * @author gvSIG team
35
 * @version $Id$
36
 */
37
public class PersonalDBDefaultImplLibrary extends AbstractLibrary {
38

  
39
    @Override
40
    public void doRegistration() {
41
        registerAsImplementationOf(PersonalDBLibrary.class);
42
        require(JDBCLibrary.class);
43
    }
44

  
45
    @Override
46
    protected void doInitialize() throws LibraryException {
47
        PersonalDBLocator.registerManager(DefaultPersonalDBManager.class);
48
    }
49

  
50
    @Override
51
    protected void doPostInitialize() throws LibraryException {
52
        if (PersonalDBLocator.getManager() instanceof DefaultPersonalDBManager) {
53

  
54
            String databasePath =
55
                System.getProperty("personalDBPath", "~/.gvsig-personaldb");
56
            String databasePort = System.getProperty("personalDBPort");
57

  
58
            String personalDBURL =
59
                databasePort == null ? "jdbc:h2:" + databasePath
60
                    : "jdbc:h2:tcp://localhost:" + databasePort + "/"
61
                        + databasePath;
62

  
63
            JDBCResourceParameters parameters = new JDBCResourceParameters();
64
            parameters.setJDBCDriverClassName("org.h2.Driver");
65
            parameters.setUrl(personalDBURL);
66

  
67
            ((DefaultPersonalDBManager) PersonalDBLocator.getManager())
68
                .open(parameters);
69
        }
70
    }
71

  
72
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/main/java/org/gvsig/personaldb/impl/DefaultPersonalDBManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.personaldb.impl;
23

  
24
import java.sql.Connection;
25
import java.sql.SQLException;
26

  
27
import javax.sql.DataSource;
28

  
29
import org.apache.commons.dbcp.BasicDataSource;
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

  
33
import org.gvsig.fmap.dal.DALLocator;
34
import org.gvsig.fmap.dal.DataServerExplorerParameters;
35
import org.gvsig.fmap.dal.DataStoreParameters;
36
import org.gvsig.fmap.dal.exception.InitializeException;
37
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
38
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
39
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer;
40
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
41
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
42
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreProvider;
43
import org.gvsig.personaldb.DBAccessException;
44
import org.gvsig.personaldb.DataServerExplorerParametersException;
45
import org.gvsig.personaldb.PersonalDBException;
46
import org.gvsig.personaldb.PersonalDBManager;
47
import org.gvsig.tools.dispose.impl.AbstractDisposable;
48
import org.gvsig.tools.exception.BaseException;
49

  
50
/**
51
 * Default {@link PersonalDBManager} implementation.
52
 * 
53
 * @author gvSIG Team
54
 * @version $Id$
55
 */
56
public class DefaultPersonalDBManager extends AbstractDisposable implements
57
    PersonalDBManager {
58

  
59
    private static final Logger LOG = LoggerFactory
60
        .getLogger(DefaultPersonalDBManager.class);
61

  
62
    private BasicDataSource dataSource;
63
    private JDBCResourceParameters resourceParameters;
64

  
65
    public Connection getConnection() throws PersonalDBException {
66

  
67
        try {
68
            return getDataSource().getConnection();
69
        } catch (SQLException e) {
70
            throw new DBAccessException(resourceParameters, e);
71
        }
72
    }
73

  
74
    private synchronized DataSource getDataSource() {
75

  
76
        if (dataSource == null) {
77
            dataSource = new BasicDataSource();
78
            dataSource.setDriverClassName(resourceParameters
79
                .getJDBCDriverClassName());
80
            dataSource.setUsername(resourceParameters.getUser());
81
            dataSource.setPassword(resourceParameters.getPassword());
82
            dataSource.setUrl(resourceParameters.getUrl());
83

  
84
            dataSource.setMaxWait(60L * 1000); // FIXME
85

  
86
            dataSource.setMaxActive(20);
87
            dataSource.setMaxIdle(4);
88
            dataSource.setMinIdle(1);
89
            dataSource.setInitialSize(1);
90

  
91
            // FIXME Set Pool parameters:
92
            /*
93
             * dataSource.setMaxOpenPreparedStatements(maxActive);
94
             * dataSource.setMaxWait(maxActive);
95
             * dataSource.setDefaultReadOnly(defaultReadOnly);
96
             * dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation
97
             * )
98
             * ;
99
             * dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis
100
             * );
101
             * dataSource.setTestOnBorrow(testOnBorrow);
102
             * dataSource.setTestOnReturn(testOnReturn);
103
             * dataSource.setTestWhileIdle(testOnReturn);
104
             * dataSource
105
             * .setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
106
             * 
107
             * dataSource.setAccessToUnderlyingConnectionAllowed(allow);
108
             * dataSource.setLoginTimeout(seconds);
109
             * dataSource.setLogWriter(out);
110
             */
111
        }
112

  
113
        return dataSource;
114
    }
115

  
116
    public DataStoreParameters getDataStoreParameters()
117
        throws PersonalDBException {
118

  
119
        return getJDBCStoreParameters();
120
    }
121

  
122
    public DataStoreParameters getDataStoreParameters(String schema,
123
        String table) throws PersonalDBException {
124

  
125
        JDBCStoreParameters params = getJDBCStoreParameters();
126
        params.setSchema(schema);
127
        params.setTable(table);
128
        return params;
129
    }
130

  
131
    private JDBCStoreParameters getJDBCStoreParameters()
132
        throws PersonalDBException {
133
        try {
134
            JDBCStoreParameters params =
135
                (JDBCStoreParameters) DALLocator.getDataManager()
136
                    .createStoreParameters(JDBCStoreProvider.NAME);
137

  
138
            params.setUrl(resourceParameters.getUrl());
139
            params.setJDBCDriverClassName(resourceParameters
140
                .getJDBCDriverClassName());
141

  
142
            return params;
143
        } catch (InitializeException e) {
144
            throw new DataServerExplorerParametersException(
145
                JDBCServerExplorer.NAME, e);
146
        } catch (ProviderNotRegisteredException e) {
147
            throw new DataServerExplorerParametersException(
148
                JDBCServerExplorer.NAME, e);
149
        }
150
    }
151

  
152
    public DataServerExplorerParameters getDataServerExplorerParameters()
153
        throws PersonalDBException {
154
        return getJDBCServerExplorerParameters();
155
    }
156

  
157
    public DataServerExplorerParameters getDataServerExplorerParameters(
158
        String schema) throws PersonalDBException {
159
        JDBCServerExplorerParameters params = getJDBCServerExplorerParameters();
160
        params.setSchema(schema);
161
        return params;
162
    }
163

  
164
    private JDBCServerExplorerParameters getJDBCServerExplorerParameters()
165
        throws PersonalDBException {
166
        try {
167
            JDBCServerExplorerParameters params =
168
                (JDBCServerExplorerParameters) DALLocator.getDataManager()
169
                    .createServerExplorerParameters(JDBCServerExplorer.NAME);
170

  
171
            params.setUrl(resourceParameters.getUrl());
172
            params.setJDBCDriverClassName(resourceParameters
173
                .getJDBCDriverClassName());
174

  
175
            return params;
176
        } catch (InitializeException e) {
177
            throw new DataServerExplorerParametersException(
178
                JDBCServerExplorer.NAME, e);
179
        } catch (ProviderNotRegisteredException e) {
180
            throw new DataServerExplorerParametersException(
181
                JDBCServerExplorer.NAME, e);
182
        }
183
    }
184

  
185
    public void open(JDBCResourceParameters resourceParameters) {
186
        LOG.debug(
187
            "Creating connection to personal database with parameters: {}",
188
            resourceParameters);
189

  
190
        this.resourceParameters = resourceParameters;
191
    }
192

  
193
    @Override
194
    protected void doDispose() throws BaseException {
195
        try {
196
            dataSource.close();
197
        } catch (SQLException e) {
198
            throw new DBAccessException(resourceParameters, e);
199
        }
200
    }
201
}
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.personaldb">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.personaldb.lib.impl</artifactId>
6
    <packaging>jar</packaging>
7
    <name>org.gvsig.personaldb.lib.impl</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.personaldb.lib</artifactId>
11
        <version>1.0.0-SNAPSHOT</version>
12
    </parent>
13
    <dependencies>
14
        <dependency>
15
            <groupId>org.gvsig</groupId>
16
            <artifactId>org.gvsig.tools.lib</artifactId>
17
            <scope>compile</scope>
18
        </dependency>
19
        <dependency>
20
            <groupId>org.gvsig</groupId>
21
            <artifactId>org.gvsig.personaldb.lib.api</artifactId>
22
            <version>1.0.0-SNAPSHOT</version>
23
            <scope>compile</scope>
24
        </dependency>
25
        <dependency>
26
            <groupId>org.gvsig</groupId>
27
            <artifactId>org.gvsig.personaldb.lib.api</artifactId>
28
            <version>1.0.0-SNAPSHOT</version>
29
            <type>test-jar</type>
30
            <scope>test</scope>
31
        </dependency>
32
        <dependency>
33
            <groupId>org.gvsig</groupId>
34
            <artifactId>org.gvsig.fmap.dal</artifactId>
35
            <scope>compile</scope>
36
        </dependency>
37
        <dependency>
38
            <groupId>org.gvsig</groupId>
39
            <artifactId>org.gvsig.fmap.dal</artifactId>
40
            <classifier>spi</classifier>
41
            <scope>compile</scope>
42
        </dependency>
43
        <dependency>
44
            <groupId>org.gvsig</groupId>
45
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
46
            <scope>compile</scope>
47
        </dependency>
48
        <dependency>
49
            <groupId>org.gvsig</groupId>
50
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
51
            <classifier>store.jdbc</classifier>
52
            <scope>compile</scope>
53
        </dependency>
54
        <dependency>
55
            <groupId>commons-dbcp</groupId>
56
            <artifactId>commons-dbcp</artifactId>
57
            <scope>compile</scope>
58
        </dependency>
59
        <dependency>
60
            <groupId>com.h2database</groupId>
61
            <artifactId>h2</artifactId>
62
            <scope>runtime</scope>
63
        </dependency>
64
        <dependency>
65
            <groupId>org.gvsig</groupId>
66
            <artifactId>org.gvsig.core.maven.dependencies</artifactId>
67
            <version>2.0.1-SNAPSHOT</version>
68
            <type>pom</type>
69
            <scope>test</scope>
70
        </dependency>
71
        <dependency>
72
            <groupId>org.slf4j</groupId>
73
            <artifactId>slf4j-api</artifactId>
74
            <scope>compile</scope>
75
        </dependency>
76
    </dependencies>
77
</project>
0 78

  
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/prepare-workspace.xml
1
<project name="org.gvsig.initial.build" default="prepare-workspace">
2

  
3
	<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" />
4

  
5
	<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." />
6
	<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" />
7
	<property name="build.jar.version" value="1.0.8-SNAPSHOT" />
8
	<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" />
9

  
10
	<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" />
11

  
12
	<target name="check-maven-base-build-available">
13
		<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" />
14
	</target>
15

  
16
	<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available">
17
		<!-- Unzip de build jar file from the maven repository into the workspace root folder -->
18
		<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false">
19
			<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}">
20
				<patternset>
21
					<exclude name="META-INF/**" />
22
				</patternset>
23
			</zipfileset>
24
		</copy>
25
	</target>
26

  
27
	<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available">
28
		<mkdir dir="target" />
29

  
30
		<!-- Download the build jar file -->
31
		<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" />
32

  
33
		<!-- Unzip de build jar file into the workspace root folder -->
34
		<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false">
35
			<zipfileset src="target/${build.jar.file}">
36
				<patternset>
37
					<exclude name="META-INF/**" />
38
				</patternset>
39
			</zipfileset>
40
		</copy>
41

  
42
	</target>
43
	
44
	<target name="find.depends.natives.file">
45
	    <condition property="depends.natives.file.exists">
46
            <available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/>
47
	    </condition>	
48
	</target>
49
	
50
	<target name="find.gvsig.platform.properties.file" 
51
			depends="find.depends.natives.file"
52
			if="depends.natives.file.exists">
53
	    <condition property="gvsig.platform.exists">
54
            <available file="${user.home}/.gvsig.platform.properties"/>
55
	    </condition>	
56
	</target>
57
	
58
	<target name="check.gvsig.platform.properties" 
59
			depends="find.gvsig.platform.properties.file">
60
		<fail if="depends.natives.file.exists" unless="gvsig.platform.exists">
61
ERROR!!
62
	
63
You have to define your gvSIG platform properties, 
64
by creating the file: ${user.home}/.gvsig.platform.properties
65
with the following content:
66

  
67
native_platform=linux
68
native_distribution=all
69
native_compiler=gcc4
70
native_arch=i386
71
native_libraryType=dynamic
72
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType}
73

  
74
Replace the fifth initial variables values with the ones appropiate 
75
to your platform.
76
	
77
If you use maven in the command line, you can use the previous file also
78
to define the MAVEN_OPTS environment variable, by adding to your 
79
.bash_rc file something like this:
80

  
81
if [ -f "${HOME}/.gvsig.platform.properties" ]
82
then
83
    . ${HOME}/.gvsig.platform.properties
84
    export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}"
85
else
86
    export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m"
87
fi
88

  
89
It will work if you use the bash shell. In any other case or platform, you'll
90
have to define your MAVEN_OPTS environment variable and set the 
91
"native-classifier" parameter directly.
92
		</fail>			
93
	
94
	</target>
95

  
96
	<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties">
97

  
98
		<mkdir dir="target" />
99

  
100
		<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" />
101

  
102
		<!-- Copy the maven launchers to the workspace metadata folder -->
103
		<copy todir="${workspace.basedir}/.metadata">
104
			<fileset dir="${build.basedir}/eclipse-launchers">
105
				<exclude name="**/org.eclipse.jdt.core.prefs" />
106
				<exclude name="**/org.eclipse.core.variables.prefs" />
107
			</fileset>
108
		</copy>
109

  
110
		<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true">
111
			<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" />
112
		</concat>
113
		<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true">
114
			<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" />
115
		</concat>
116

  
117
		<!-- Configure the eclipse workspace -->
118
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" />
119

  
120
		<!-- Configure the gvSIG profile -->
121
		<ant antfile="${build.basedir}/check-gvsig-profile.xml" />
122

  
123
		<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" />
124

  
125
		<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
126
			<classpath>
127
				<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" />
128
			</classpath>
129
		</taskdef>
130

  
131
		<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}">
132
			<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" />
133
		</xmltask>
134

  
135
		<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" />
136
		<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" />
137

  
138
		<!-- Compile, install and generate eclipse projects -->
139
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" />
140

  
141
		<echo>INFORMATION!!!</echo>
142
		<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo>
143

  
144
		<!-- TODO: copiar al proyecto de configuraciĆ³n general -->
145
	</target>
146

  
147
	<target name="clean">
148
		<delete dir="target" />
149
	</target>
150
	
151
</project>
tags/v2_0_0_Build_2049/libraries/org.gvsig.personaldb/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
    <modelVersion>4.0.0</modelVersion>
6
    <artifactId>org.gvsig.personaldb</artifactId>
7
    <packaging>pom</packaging>
8
    <version>1.0.0-SNAPSHOT</version>
9
    <name>org.gvsig.personaldb</name>
10
    <description>PersonalDB example project</description>
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.maven.base.pom</artifactId>
14
        <version>1.0.8-SNAPSHOT</version>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff