Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Added Copyright notice to all Java files. This had the side-effect of…
Browse files Browse the repository at this point in the history
… changing the line delimiter to the Unix format. As such, some files have had all their lines affected, others only a subset.
  • Loading branch information
plaflamme committed Oct 16, 2008
1 parent aa4b511 commit 90ee61b
Show file tree
Hide file tree
Showing 366 changed files with 34,307 additions and 30,348 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

@@ -1,51 +1,60 @@
package org.obiba.onyx.cartagene.etl.participant;

import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.obiba.onyx.core.domain.participant.Appointment;
import org.obiba.onyx.core.domain.participant.Gender;
import org.obiba.onyx.core.domain.participant.Participant;
import org.obiba.onyx.core.domain.participant.Province;
import org.obiba.onyx.core.etl.participant.AbstractParticipantExcelReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ParticipantExcelReader extends AbstractParticipantExcelReader {

@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(ParticipantExcelReader.class);

protected Participant processParticipant(HSSFRow row, HSSFFormulaEvaluator evaluator) {
Participant participant = new Participant();

participant.setSiteNo(getTextValue(row, evaluator, row.getCell(2)));
participant.setFirstName(getTextValue(row, evaluator, row.getCell(5)));
participant.setLastName(getTextValue(row, evaluator, row.getCell(4)));
Long id = getNumericValue(row, evaluator, row.getCell(3)).longValue();
participant.setEnrollmentId(id == null ? null : id.toString());
participant.setBirthDate(getDateValue(row, evaluator, row.getCell(7)));
String gender = getTextValue(row, evaluator, row.getCell(6));
if(gender.equals("M")) {
participant.setGender(Gender.MALE);
} else if(gender.equals("F")) {
participant.setGender(Gender.FEMALE);
}
participant.setStreet(getTextValue(row, evaluator, row.getCell(8)));
participant.setCity(getTextValue(row, evaluator, row.getCell(9)));
participant.setProvince(Province.valueOf(getTextValue(row, evaluator, row.getCell(10))));
participant.setCountry(getTextValue(row, evaluator, row.getCell(11)));
participant.setPostalCode(getTextValue(row, evaluator, row.getCell(12)));
participant.setPhone(getTextValue(row, evaluator, row.getCell(13)));

return participant;
}

protected Appointment processAppointment(HSSFRow row, HSSFFormulaEvaluator evaluator) {
Appointment appointment = new Appointment();

appointment.setAppointmentCode(getTextValue(row, evaluator, row.getCell(3)));
appointment.setDate(getDateValue(row, evaluator, row.getCell(0)));

return appointment;
}
}
/*******************************************************************************
* Copyright 2008(c) The OBiBa Consortium. All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package org.obiba.onyx.cartagene.etl.participant;

import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.obiba.onyx.core.domain.participant.Appointment;
import org.obiba.onyx.core.domain.participant.Gender;
import org.obiba.onyx.core.domain.participant.Participant;
import org.obiba.onyx.core.domain.participant.Province;
import org.obiba.onyx.core.etl.participant.AbstractParticipantExcelReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ParticipantExcelReader extends AbstractParticipantExcelReader {

@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(ParticipantExcelReader.class);

protected Participant processParticipant(HSSFRow row, HSSFFormulaEvaluator evaluator) {
Participant participant = new Participant();

participant.setSiteNo(getTextValue(row, evaluator, row.getCell(2)));
participant.setFirstName(getTextValue(row, evaluator, row.getCell(5)));
participant.setLastName(getTextValue(row, evaluator, row.getCell(4)));
Long id = getNumericValue(row, evaluator, row.getCell(3)).longValue();
participant.setEnrollmentId(id == null ? null : id.toString());
participant.setBirthDate(getDateValue(row, evaluator, row.getCell(7)));
String gender = getTextValue(row, evaluator, row.getCell(6));
if(gender.equals("M")) {
participant.setGender(Gender.MALE);
} else if(gender.equals("F")) {
participant.setGender(Gender.FEMALE);
}
participant.setStreet(getTextValue(row, evaluator, row.getCell(8)));
participant.setCity(getTextValue(row, evaluator, row.getCell(9)));
participant.setProvince(Province.valueOf(getTextValue(row, evaluator, row.getCell(10))));
participant.setCountry(getTextValue(row, evaluator, row.getCell(11)));
participant.setPostalCode(getTextValue(row, evaluator, row.getCell(12)));
participant.setPhone(getTextValue(row, evaluator, row.getCell(13)));

return participant;
}

protected Appointment processAppointment(HSSFRow row, HSSFFormulaEvaluator evaluator) {
Appointment appointment = new Appointment();

appointment.setAppointmentCode(getTextValue(row, evaluator, row.getCell(3)));
appointment.setDate(getDateValue(row, evaluator, row.getCell(0)));

return appointment;
}
}
@@ -1,114 +1,123 @@
package org.obiba.onyx.cartagene.hibernate.util;

import java.io.ByteArrayInputStream;
import java.util.Properties;
import java.util.Set;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.FileSystemResource;

public class CreateDDL {

// System constants for the current platform directory token
static String fileSep = System.getProperty("file.separator");

private String path = "";

private static GenericApplicationContext appContext;

public static void main(String args[]) {

// Create application context.
appContext = loadAppContext();

CreateDDL c = new CreateDDL();
c.createDDL();
System.err.println("Finish");
}

protected static GenericApplicationContext loadAppContext() {

// Load bootstrap context files.
GenericApplicationContext appContext = new GenericApplicationContext();
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appContext);
xmlReader.loadBeanDefinitions(new FileSystemResource("src/main/webapp/WEB-INF/spring/context.xml"));
appContext.refresh();

return appContext;
}

protected static Properties loadServiceParams(String[] args) {

Properties params = new Properties();
try {

params.loadFromXML(new ByteArrayInputStream(args[0].getBytes("UTF-8")));
return params;

} catch(Exception wErrorLoadingXml) {
throw new RuntimeException("Error! Client was unable to load application parameters.");
}

}

public CreateDDL() {
}

private AnnotationConfiguration getConfiguration() {
try {
AnnotationConfiguration conf = new AnnotationConfiguration();

Set<Class<?>> annotatedClasses = (Set<Class<?>>) appContext.getBean("annotatedHibernateClasses");
for(Class cl : annotatedClasses) {
conf.addAnnotatedClass(cl);
}

// naming strategie
conf.setNamingStrategy(ImprovedNamingStrategy.INSTANCE);

Properties props = new Properties();
props.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");

conf.addProperties(props);
return conf;
} catch(Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
}

/**
* Loads the Hibernate configuration information, sets up the database and the Hibernate session factory.
*/
public void createDDL() {
System.out.println("testCreateDDL");
try {
Configuration conf = getConfiguration();
String dialect_file = "mysql.sql";

System.out.println("Generating: " + dialect_file);
SchemaExport mySchemaExport = new SchemaExport(conf, conf.buildSettings());
mySchemaExport.setDelimiter(";");

// Despite the name, the generated create
// scripts WILL include drop statements at
// the top of the script!
mySchemaExport.setOutputFile(path + "create_" + dialect_file);
mySchemaExport.create(false, false);

// Generates DROP statements only
mySchemaExport.setOutputFile(path + "drop_" + dialect_file);
mySchemaExport.drop(false, false);

System.out.println(dialect_file + " OK.");
} catch(Exception e) {
e.printStackTrace();
}
}

}
/*******************************************************************************
* Copyright 2008(c) The OBiBa Consortium. All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package org.obiba.onyx.cartagene.hibernate.util;

import java.io.ByteArrayInputStream;
import java.util.Properties;
import java.util.Set;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.FileSystemResource;

public class CreateDDL {

// System constants for the current platform directory token
static String fileSep = System.getProperty("file.separator");

private String path = "";

private static GenericApplicationContext appContext;

public static void main(String args[]) {

// Create application context.
appContext = loadAppContext();

CreateDDL c = new CreateDDL();
c.createDDL();
System.err.println("Finish");
}

protected static GenericApplicationContext loadAppContext() {

// Load bootstrap context files.
GenericApplicationContext appContext = new GenericApplicationContext();
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appContext);
xmlReader.loadBeanDefinitions(new FileSystemResource("src/main/webapp/WEB-INF/spring/context.xml"));
appContext.refresh();

return appContext;
}

protected static Properties loadServiceParams(String[] args) {

Properties params = new Properties();
try {

params.loadFromXML(new ByteArrayInputStream(args[0].getBytes("UTF-8")));
return params;

} catch(Exception wErrorLoadingXml) {
throw new RuntimeException("Error! Client was unable to load application parameters.");
}

}

public CreateDDL() {
}

private AnnotationConfiguration getConfiguration() {
try {
AnnotationConfiguration conf = new AnnotationConfiguration();

Set<Class<?>> annotatedClasses = (Set<Class<?>>) appContext.getBean("annotatedHibernateClasses");
for(Class cl : annotatedClasses) {
conf.addAnnotatedClass(cl);
}

// naming strategie
conf.setNamingStrategy(ImprovedNamingStrategy.INSTANCE);

Properties props = new Properties();
props.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");

conf.addProperties(props);
return conf;
} catch(Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
}

/**
* Loads the Hibernate configuration information, sets up the database and the Hibernate session factory.
*/
public void createDDL() {
System.out.println("testCreateDDL");
try {
Configuration conf = getConfiguration();
String dialect_file = "mysql.sql";

System.out.println("Generating: " + dialect_file);
SchemaExport mySchemaExport = new SchemaExport(conf, conf.buildSettings());
mySchemaExport.setDelimiter(";");

// Despite the name, the generated create
// scripts WILL include drop statements at
// the top of the script!
mySchemaExport.setOutputFile(path + "create_" + dialect_file);
mySchemaExport.create(false, false);

// Generates DROP statements only
mySchemaExport.setOutputFile(path + "drop_" + dialect_file);
mySchemaExport.drop(false, false);

System.out.println(dialect_file + " OK.");
} catch(Exception e) {
e.printStackTrace();
}
}

}

0 comments on commit 90ee61b

Please sign in to comment.