Skip to content
Alejandro Medrano Gil edited this page May 25, 2015 · 3 revisions

<< prev | 1 2 [3] 4 | next >>





During development

Table of Contents

IPR management

About Intelectual Property Rights (IPR) management, you should take into account several considerations. For more information check the D2.3 or D9.3. First of all, software from input projects is under special conditions. But for every new piece of code developed within uAAL IPR must be applied since the beginning (following ASL2.0 procedure):

  • Include a Disclaimer for the header of every source file
    • By reporting a copyright notice for all the involved authors
    • Do not remove the copyright notices of included/modified source files
    • Include a reference to the Notice file for the list of all required licenses
  • List all the required licenses for the external code
    • included in your software from which your code was (partially) derived
    • used at runtime
    • optionally used at compile time
  • Check the compatibility of licenses used
    • i.e. you cannot license with ASL if you include GPL
  • Prepare a copy of each different license
  • Create the Notice file
    • By providing all the required credits
    • By listing all the included/modified/used software
  • Include in your software package or project repository
    • The Notice file
    • The License file adopted for the developed code
    • All the License files adopted by the software you used
  • Maintain regularly updated the Notice file as soon as you create dependency with other software
  • Maintain regularly updated the IPR directory (The IPR manager of the partner should do this)

The license adopted by universAAL: ASL 2.0

The Apache Software License is the license that should be applied to all new software produced in universAAL, unless you have a very good reason to choose otherwise and communicate it appropriately. With an ASL 2.0 license, the users can do whatever they want with the software, including releasing it as proprietary software, whether modified or not. For licensing with ASL 2.0 without problems, no dependencies should be used that are licensed with licenses other than ASL, MIT or BSD, or other permissive copyleft licenses.

Disclaimer

Every source file of a software module released under OS License should have as header a disclaimer reporting copyright information, the license applied to the software and a link to the Notice file with detailed information about the all the software licenses associated to the software module.

Copyright 2008-2014 Fraunhofer IGD, http://www.igd.fraunhofer.de Fraunhofer Gesellschaft - Institut fuer Graphische Datenverarbeitung See the NOTICE file distributed with this work for additional information regarding copyright ownership Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Notice file

The Notice file is a text file reporting the most important information about the software module. The typical information reported is:

  • The included software in case of derivative work
  • The software used, for example the libraries linked by the module
  • Any other important information for example the reference to any specification implemented by the software
  • A summary of the licenses applied by the software
Realization of the Middleware Context Bus as a Sodapop Bus Copyright 2007-2014 Fraunhofer IGD, http://www.igd.fraunhofer.de Fraunhofer Gesellschaft - Institut für Graphische Datenverarbeitung I. Included Software Software developed by Fraunhofer IGD within the PERSONA project is used as the initial version for further developments within the universAAL project, under the Apache License 2.0. II. Used Software This product uses software developed at The Apache Software Foundation (http://www.apache.org/). Licensed under the Apache License 2.0. This product uses software developed at Junit (http://www.junit.org/). Licensed under Common Public License 1.0. III. License Summary - Apache License 2.0 - Common Public License 1.0

Naming & versioning

These naming and versioning conventions are universAAL driven and must be followed during the development of new applications:

  • When you create a new project with the AAL Studio, you should take into account the following rules:
    • Group ID: org.universAAL.AALapplication (it must not be changed)
    • Artifact ID: Same as SVN folder.
      • service_name.bundle_name: In case the service is composed by one bundle then it should be called nutritional.service. Otherwise, it will be called e.g. nutritional.bundle_name1, nutritional.bundle_name1, etc. Folders of each new service are already created in the SVN of the new_services GForge project (by default it's assumed that each service is composed by one bundle) as follow:
        • aal_eficiency/service
        • agenda/service
        • food_shopping/service
        • health/service
        • help_when_out/service
        • long_term_behav/service
        • medication/service
        • nutritional/service
        • personal_safety/service
        • safety_home/service
  • Version numbering strategy:
    • Release.Major.Minor-SUFFIX (SERVICENAME-X.0.0-SNAPSHOT)
      • SERVICENAME: Identify the name of the service, i.e. NutritionalAdvisor, HelpWhenOutdoor, Agenda, etc.
      • X.0: Identify the release version from WP2. WP2 1.2.0 release is known as X.0 release in WP4.
      • .0: Identify the number of version of our service as long as we are using this current release. Always it starts in 0 and is increased each time there is a new relevant version of the service.
      • SNAPSHOT: It is removed when the service is released.
      • i.e: nutritionalAdvisor-B.1.1-SNAPSHOT (SNAPSHOT)
      • i.e: nutritionalAdvisor-B.1.1 (RELEASE)

Code style

When writing code it is recommended that you follow a certain style: Sun code conventions. It covers indentation, spaces, brackets, etc. Conformance tools will help you to revise the code automatically. There will be available specific conformance tools for the development and test phase. Furthermore, by setting the sun code conventions in the formatting preferences of Eclipse then automatically you can format great part of the code with: Ctrl + shift + F. It is also explained in D2.3-D

Apache Derby Database

Overview

Apache Derby Database is an open source relational database implemented entirely in Java and available under the Apache License, Version 2.0. This license is one of the main motivations to do the migration, since we can only use MySQL in universAAL getting advantage of certain license exceptions. Using a database under the same license as universAAL is better for the project release. Also, Derby has other advantages, such as small footprint (about 2.6 megabytes for the base engine and embedded JDBC driver), is based on the Java, JDBC, and SQL standards, and provides an embedded JDBC driver that lets you embed Derby in any Java-based solution. Also, you don’t need to install any managers on your computer, so using Derby eliminated the necessity of installing any managers in the final user’s computers. By default, the database will be in the rundir folder of the service.

Start using Derby

In order to start using Derby you just need to import the reference in your pom file as:

   <dependency>
       <groupId>org.apache.derby</groupid>
       <artifactId>derby</artifactid>
       <version>10.7.1.1</version>
   </dependency>

And add the import of the driver, the same way as MySQL driver:

    <instructions>
        <Bundle-Name>${project.name}</bundle-name>
        <Bundle-Activator>org.univerAAL.AALapplication.dbExample.Activator</bundle-activator>
        <Bundle-Description>${project.description}</bundle-description>
        <Bundle-SymbolicName>${project.artifactId}</bundle-symbolicname>
        <Export-Package>org.univerAAL.AALapplication.dbExample</export-package>
        <Import-Package>org.apache.derby.jdbc, org.osgi.framework, org.universAAL.middleware.container</import-package>
    </instructions>

Database Encryption

Derby allows you to configure a database for encryption when you create it. To do so, you specify dataEncryption=true on the connection URL. For J2SE/J2EE 1.4 or higher, the JRE's provider is the default encryption provider.

Derby offers complete encryption of the on-disk data

  • Data files for indexes and tables
  • Transaction Log File
  • Temporary files (for ORDER BY etc.)
It includes application data and system data
  • Table data
  • All system catalog/metadata information
What’s Not Encrypted
  • Data in-memory(Page cache contents and ResultSets)
  • service.properties file (Only contains minimal information to boot database but can contain some encryption related information)
  • Jar files stored in the database through sqlj.install_jar
  • derby.log – error log
You can find the explanation on how to use encryption here

The Database Interface

This section describes the syntax to connect to the database, create it and access the data. In order to use the driver you first need to import it wherever you want to access to the database, same as the MySQL driver:

    Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();

To access to your database:

  Connection connect = DriverManager.getConnection("jdbc:derby:"+DBNAME+";create=true;");

You use create=true if you want to create the database at that time, otherwise you can just omit that.

Creating a table and inserting values

You can create tables using SQL syntax. You need to take care to put the name of the database followed by .TABLENAME (in red in the example).

    String createTableCar = "CREATE TABLE  "+DBNAME+".car ( id integer PRIMARY KEY NOT NULL GENERATED ALWAYS AS 
    IDENTITY (START WITH 1, INCREMENT BY 1), model  varchar(25),colour  varchar(25))";
    statement.executeUpdate(createTableCar);

The following example shows the syntax to create a foreign key.

    String createTableBought = "CREATE TABLE  "+DBNAME+".bought ( id integer PRIMARY KEY NOT NULL GENERATED ALWAYS
    AS IDENTITY (START WITH 1, INCREMENT BY 1), car integer, client integer, bought_date DATE, price integer, CONSTRAINT 
    car_fk FOREIGN KEY (car) REFERENCES "+DBNAME+".car(id), CONSTRAINT client_fk FOREIGN KEY(client)  
    REFERENCES "+DBNAME+".client(dni))";
    statement.executeUpdate(createTableBought);

In order to insert values to a table, the syntax is

    statement.executeUpdate("insert into "+DBNAME+".car (model, colour) values ('A6','White')");

Be careful to put strings and dates between quotes and integers and boolean without quotes.

Select and update rows

You can select rows with restrictions like:

    ResultSet = statement.executeQuery("select * from "+DBNAME+".car where model='A6'");

And returns a result set you can use with same as the MySQL results. Updates are also similar to the ones in MySQL

    statement3.executeUpdate("UPDATE "+DBNAME+".bought SET price=45000 WHERE id=1");

Migration from MySQL

In order to migrate to Apache Derby you have two options.




Final Considerations

  • Call your database with the same name as the main service that uses it and place it in the service configuration folder. When you run the service from Eclipse it is located at /rundir/configurations/ folder. To define relative URLs to your DB (A relative path is relative to the value of the system property derby.system.home) add the following code to your service:
            String configFolderPath = System.getProperty(
                    BundleConfigHome.uAAL_CONF_ROOT_DIR, System
                            .getProperty("user.dir"));
            if(configFolderPath.substring(configFolderPath.length() - 1)!="/"){
                 configFolderPath+="/";
            }   
            System.setProperty("derby.system.home", configFolderPath);
            String dbURL = "jdbc:derby:" + configFolderPath
                    + "wp4ServiceName/wp4ServiceDatabaseName;create=true";








Tips for making your life easier

Why Maven is not working any more

It seems there is a radical change in the latest Maven version (3.1.0) and could affect some compilations. DO NOT USE the latest Maven version (3.1.x), use a 3.0.x version instead.

Memory problem running universAAL

If you have memory problems running your service in Eclipse create an environment variable associated to the current user as follow and your problems will disappear:

  MAVEN_OPTS
  –Xmx512m –XX:MaxPermSize=256m

Avoiding long start ups in Eclipse

A small tip in case your run config takes ~very~ long to start up: one of the servers that is somewhere referenced in a maven file is down (scm.ops4j.org). You can considerably increase the starting procedure by adding the following line to your hosts-file under C:\Windows\System32\drivers\etc\hosts. You may need to run a Notepad app with admin privileges for being able to save the modifications --> 127.0.0.1 scm.ops4j.org

org.ops4j.pax.scannerException

If you get the following error when trying to run your new configuration (launch file). First of all, just try again. But if the problem persists, don't worry, it happens sometimes when the rundir cache crashes so you can fix it :).

  • Close Eclipse
  • Go to your workspace (i.e. C:\universAAL\dev\workspaces\prototype\rundir\help_when_outdoor\runner)
  • Remove the following folders:
  /bundles
  /cache
  • Open Eclipse again
  • Open Run Configurations again
  • Try to run your configuration file again. If you get the same error, just click on OK button and try again. You might need several attempts but believe me...it works ;).

Figure 3. Problem when trying to run your service

Export your configuration file (.launch)

If you want to copy your run run configuration file (.launch) to other location and don't find where. It is because is storaged locally and not accessible, BUT it can be changed by modifying the following option at Run Configuration file

Figure 4. Configuring location of your launcher file

In Common tag, select the "Shared file" option and specify where you want to be stored your launcher file.

What to do when Eclipse says that your code has errors and you don't believe it

Updates for Maven Projects

  • Right-click on selected project
  • Select MAVEN menu
  • Click on UPDATE PROJECT CONFIGURATION... option
  • Again right-click on selected project
  • Select MAVEN menu
  • Click on UPDATE MAVEN DEPENDENCIES option

Remove Target folder

  • Just that, remove Target folder of your project
  • Refresh the project, then Eclipse will create again the jar file

Disable Workspace

Some times Eclipse doesn't find the dependencies because is looking for in the workspace. To solve it:

  • Right-click on selected project
  • Select MAVEN menu
  • Click on DISABLE WORKSPACE RESOLUTION option
Then Eclipse will look for the dependencies in your .m2 local repo.

Change java version in project

  • Right-click on selected project
  • Click on PROPERTIES option
  • Go to JAVA COMPILER
  • Uncheck "use compliance from execution environment 'J2SE-1.5' on the 'Java Build Path'" option
  • Select another java version that you have available at "Compiler compliance level"
  • Click on APPLY button
  • Click on OK button
  • Then wait for Eclipse until it has rebuilt the whole workspace. It may take some time, but force it to regenerate .class
  • Change your Eclipse again to the right Java version.

Why do I see as uninstalled features that are already installed in universAAL karaf-based distributions

  • Wait while features are (downloaded and) installed
  • Type "list" several times to see which bundles have been installed until now. only when all bundles are started feature will be seen as intalled.

Key shorcuts

How to open a Command Prompt directly in the path you want

  • Open a Windows Explorer window, and browse the folder where you want to open the console.
  • Hold the SHIFT key while you right-click the folder.
  • Select Open Command Prompt Here option.

How to copy text after being marked in a Command Prompt

  • Right-click on the console
  • Select Mark option
  • Select text in the console
  • Click INTRO

How to add System.out.println() lines automatically

  • Type syso where you want to add the code line
  • Click on CTRL plus SPACE at the same time

Cool console commands

Check what packages are exported/imported by a bundle

  • headers BUNDLE_NUMBER

Javadoc

Each service must generate javadoc. For more information consult Tips'n Tricks on Javadoc writing wikipage.

Semantic Framework

Ontologies are good for you and their purpose is to share knowledge. If AAL services share knowledge then it will make development of all services easier, it will avoid re-modelling already modelled knowledge, and will make the interoperation of AAL services Smooth.

To easily share the ontologies the procedure to design new ontologies is as follows:

  1. Go to de INDEX and study available ontologies
  2. If no ontology fits your interest then start new design:
    1. Create a new wikipage (ontologies domain)
    2. Add the link to the ontology index
    3. Report it in wiki. Each wiki page should contain at least:
      1. Responsible partner and person
      2. Domain (which area of interest will the ontology cover), Associated service
      3. Development Status
      4. Class Diagram
      5. Concept description (for every concept)
  3. Implement the Ontology. The code should go inside each service subfolder in the SVN



Ontology feature requests

To request new features for an ontology use the Gforge tracker of the associated service, or the general tracker of the responsible EG. For detailed feature request the wikipage of the ontology may be used.

In the case that the ontology is generalized (by this process of feature requesting) enough; then the Ontology may be transfered to the Ontologies GForge proyect (wiki + code).

Implementing Ontologies

see:

Configuration files

If your AAL Service needs configuration values to make it runnable, you must use the Configuration Extractor (CE) tool. The idea is that all AAL Service values are marked in the source code with the CE. Then during the AAL Service installation process the universAAL Control Center (uCC) tool generates the configuration file.

Note: At the moment, there is any agreement between the uCC tool and generation of AAL Services regarding configuration files, but as general convention to follow in WP4, all the configuration files will be created in the configurations/SERVICE_NAME/SERVICE_NAME.properties.

Testing Strategy

The testing strategy defined will be test driven development and continuous integration. Set up the whole running platform to run your code and check that everything works (system level tests).

  • The universAAL platform code used should be the one available from the Developer Depot Nexus repository. If something doesn't work, report as bug!
  • In the new_services GForge project exists a tracker per each universAAL service (click '''here''' to see an use example applied to WP4), where you can report/suggest:
    • Bugs
    • Support
    • Patches
    • New features
    • To-Do
At that point, also conformance tools will be involved in the testing phase.

Chapters