import java.util.ArrayList;
import java.util.List;
-import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
+import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.api.service.ICollectionService;
import eu.etaxonomy.cdm.api.service.ICommonService;
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
import eu.etaxonomy.cdm.api.service.IReferenceService;
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.ITaxonService;
-import eu.etaxonomy.cdm.api.service.ITaxonTreeService;
import eu.etaxonomy.cdm.api.service.ITermService;
import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.api.service.IVocabularyService;
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;
-import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
import eu.etaxonomy.cdm.database.DbSchemaValidation;
import eu.etaxonomy.cdm.database.ICdmDataSource;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;
-import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
import eu.etaxonomy.taxeditor.datasource.view.CdmDataSourceViewPart;
-import eu.etaxonomy.taxeditor.dialogs.LoginDialog;
import eu.etaxonomy.taxeditor.io.ExportHandler;
import eu.etaxonomy.taxeditor.io.ImportHandler;
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
-import eu.etaxonomy.taxeditor.model.IContextListener;
-import eu.etaxonomy.taxeditor.model.IContextListener.EventType;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
- * This implementation of ICdmDataRepository depends on hibernate sessions to store the data correctly
+ * This implementation of ICdmDataRepository depends on hibernate sessions to store the data correctly
* for the current session. No state is held in this class.
- *
- * Only methods that either get or manipulate data are exposed here. So this class acts as a facade
- * for the methods in cdmlib-service.
- *
- *
+ *
+ * Only methods that either get or manipulate data are exposed here. So this class acts as a facade
+ * for the methods in cdmlib-service.
+ *
* @author n.hoffmann
* @created 17.03.2009
* @version 1.0
*/
public class CdmStore{
- private static final Logger logger = Logger.getLogger(CdmStore.class);
private static class CdmDataStoreConnector implements IRunnableWithProgress{
- private ICdmDataSource datasource;
+ private ICdmDataSource dataSource;
private DbSchemaValidation dbSchemaValidation;
private Resource applicationContextBean;
- private IProgressMonitor monitor;
/**
* @param datasource
public CdmDataStoreConnector(ICdmDataSource datasource,
DbSchemaValidation dbSchemaValidation,
Resource applicationContextBean) {
- this.datasource = datasource;
+ this.dataSource = datasource;
this.dbSchemaValidation = dbSchemaValidation;
this.applicationContextBean = applicationContextBean;
}
-
-
- public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
- this.monitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor();
-
+ public void run(final IProgressMonitor monitor) {
+
monitor.beginTask(getConnectionMessage(), 10);
- checkDatabaseReachable();
+ // check if database is up and running
+ checkDatabaseReachable(monitor);
if(! monitor.isCanceled()){
- checkDatabaseNotEmpty();
+ // check if the datasource actually holds data
+ checkDatabaseNotEmpty(monitor);
}
- if(! monitor.isCanceled()){
- checkDbSchemaVersionCompatibility();
+ if(dbSchemaValidation != DbSchemaValidation.CREATE && ! monitor.isCanceled()){
+ // if we do not create the datasource, we want to check if the datasource is compatible with this editor
+ checkDbSchemaVersionCompatibility(monitor);
}
// we are done with our low level checking and will free resources now
- datasource.closeOpenConnections();
+ dataSource.closeOpenConnections();
if(! monitor.isCanceled()){
- instance = new CdmStore(datasource, dbSchemaValidation, applicationContextBean, new CdmProgressMonitorAdapter(monitor));
- notifyContextStart(monitor);
- logger.info("Application context initialized.");
+ close(monitor);
+ }
+
+ CdmApplicationController applicationController = null;
+
+ if(! monitor.isCanceled()){
+ CdmProgressMonitorAdapter subprogressMonitor = CdmProgressMonitorAdapter.CreateSubMonitor(monitor, 5);
+ // This is where we instantiate the application controller
+ try{
+ applicationController = CdmApplicationController.NewInstance(applicationContextBean, dataSource, dbSchemaValidation, false, subprogressMonitor);
+ }catch(Exception e){
+ StoreUtil.error(this.getClass(), e.getMessage(), e);
+ }
+ }
+
+ if(! monitor.isCanceled()){
+ setInstance(applicationController, dataSource);
+
+ getContextManager().notifyContextStart(monitor);
+
+ monitor.done();
+ StoreUtil.info("Application context initialized.");
}else{
// Show datasource view if not shown yet
StoreUtil.showView(CdmDataSourceViewPart.ID);
}
-
- monitor.done();
}
*/
private String getConnectionMessage() {
String message = "";
- if(datasource.getDatabaseType().equals(DatabaseTypeEnum.H2)){
+ if(dataSource.getDatabaseType().equals(DatabaseTypeEnum.H2)){
message = " local CDM Store ";
}else{
message = " CDM Community Store ";
}
- message += "'" + datasource.getName() + "'";
+ message += "'" + dataSource.getName() + "'";
message = "Connecting to" + message + ".";
* @return
* @throws SQLException
*/
- private void checkDbSchemaVersionCompatibility() {
+ private void checkDbSchemaVersionCompatibility(IProgressMonitor monitor) {
+ monitor.subTask("Checking if datasource is compatible with this editor.");
String dbSchemaVersion;
boolean result = false;
try {
- dbSchemaVersion = (String) datasource.getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
+ dbSchemaVersion = (String) dataSource.getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
// we assume that empty dbSchemaVersion means an empty database and skip version checking
result = dbSchemaVersion == null ? true : CdmMetaData.isDbSchemaVersionCompatible(dbSchemaVersion);
+ monitor.worked(1);
} catch (SQLException e) {
//
}
if(!result){
// Show an error message
- StoreUtil.errorDialog("DatabaseCompatibilityCheck failed", "The database schema for the chosen " +
- "datasource '" + datasource + "' \n is not valid for this version of the taxonomic editor. \n" +
- "Please update the chosen datasource or choose a new data source to connect to in the Datasource View.");
+ StoreUtil.errorDialog("DatabaseCompatibilityCheck failed", this, "The database schema for the chosen " +
+ "datasource '" + dataSource + "' \n is not valid for this version of the taxonomic editor. \n" +
+ "Please update the chosen datasource or choose a new data source to connect to in the Datasource View.", null);
monitor.setCanceled(true);
}
}
- private void checkDatabaseNotEmpty() {
+ private void checkDatabaseNotEmpty(IProgressMonitor monitor) {
monitor.subTask("Checking if datasource is not empty.");
- DatabaseMetaData metaData = datasource.getMetaData();
+ DatabaseMetaData metaData = dataSource.getMetaData();
if(metaData != null){
try {
- ResultSet resultSet = metaData.getTables(datasource.getDatabase(), null, null, null);
+ ResultSet resultSet = metaData.getTables(dataSource.getDatabase(), null, null, null);
if (resultSet != null){
- if(resultSet.next()){
- return;
- }else{
- if(StoreUtil.confirmDialog("Database is empty", "Do you want to create the datasource?")){
- dbSchemaValidation = DbSchemaValidation.CREATE;
- return;
- }
+ if(! resultSet.next()){
+ dbSchemaValidation = DbSchemaValidation.CREATE;
}
+ monitor.worked(1);
+ return;
}
} catch (SQLException e) {
- StoreUtil.errorDialog("Error while trying to retrieve database metadata", "Something is utterly wrong with your database.");
- logger.error(e);
+ StoreUtil.errorDialog("Error while trying to retrieve database metadata", this, "Something is utterly wrong with your database.", e);
+ StoreUtil.error(this.getClass(), e.getMessage(), e);
}
}
monitor.setCanceled(true);
}
- private void checkDatabaseReachable(){
+ private void checkDatabaseReachable(IProgressMonitor monitor){
try {
monitor.subTask("Checking if datasource is reachable.");
- datasource.testConnection();
+ dataSource.testConnection();
monitor.worked(1);
- } catch (DataSourceNotFoundException e) {
- StoreUtil.errorDialog("Chosen Datasource is not available", "Could not connect to the chosen " +
- "datasource '" + datasource + "'. Please check settings in datasources.xml. If the datasource " +
- "is located on a remote machine, make sure you are connected to the network.");
+ } catch (ClassNotFoundException e) {
+ StoreUtil.errorDialog("Could not connect to chosen datasource", this, "Reason: " + e.getMessage(), e);
+ monitor.setCanceled(true);
+ } catch (SQLException e) {
+ StoreUtil.errorDialog("Could not connect to chosen datasource", this, "Reason: " + e.getMessage(), e);
monitor.setCanceled(true);
}
}
}
- private static final Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource("/eu/etaxonomy/cdm/editorApplicationContext.xml", TaxeditorStorePlugin.class.getClassLoader());
+
+
+ private static final Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource("/eu/etaxonomy/cdm/editorApplicationContext.xml", TaxeditorStorePlugin.class);
private static final DbSchemaValidation DEFAULT_DB_SCHEMA_VALIDATION = DbSchemaValidation.VALIDATE;
private static CdmStore instance;
private static ExportHandler exportHandler;
- private Language language;
+ private static ContextManager contextManager;
- private static ListenerList contextListeners = new ListenerList();
+ private Language language;
- private static ICdmDataSource cdmDatasource;
+ private ICdmDataSource cdmDatasource;
private boolean isConnected;
/**
- *
- * @param applicationContextBean
- * @return
+ * <p>getDefault</p>
+ *
+ * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
*/
protected static CdmStore getDefault(){
if(instance != null && instance.isConnected){
return instance;
- }else if(instance == null){
-
- initialize();
-
- return instance;
- }else if(!instance.isConnected){
-
- StoreUtil.warningDialog("No datasource connection", "Application is not connected to a datastore.");
+ }else if(instance == null || !instance.isConnected){
+
+ StoreUtil.warningDialog("Application is not connected to a datastore", instance, "The requested operation is only available when " +
+ "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
- // TODO open datasource view
+ StoreUtil.showView(CdmDataSourceViewPart.ID);
}
return null;
/**
* Initialize the with the last edited datasource
*/
- public static void initialize() {
+ public static void connect() {
ICdmDataSource datasource = CdmDataSourceRepository.getCurrentDataSource();
- initialize(datasource);
+ connect(datasource);
}
/**
* Initialize with a specific datasource
- *
- * @param datasource
+ *
+ * @param datasource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
*/
- public static void initialize(ICdmDataSource datasource) {
- initialize(datasource, DEFAULT_DB_SCHEMA_VALIDATION, DEFAULT_APPLICATION_CONTEXT);
+ public static void connect(ICdmDataSource datasource) {
+ connect(datasource, DEFAULT_DB_SCHEMA_VALIDATION, DEFAULT_APPLICATION_CONTEXT);
}
/**
* @param dbSchemaValidation
* @param applicationContextBean
*/
- private static void initialize(final ICdmDataSource datasource, final DbSchemaValidation dbSchemaValidation, final Resource applicationContextBean){
- if(isActive()){
- logger.error("Application context already initialized.");
- return;
- }
-
- logger.info("Initializing application context ...");
+ private static void connect(final ICdmDataSource datasource, final DbSchemaValidation dbSchemaValidation, final Resource applicationContextBean){
+ StoreUtil.info("Connecting to datasource: " + datasource);
try {
-
- CdmDataStoreConnector runnable = new CdmDataStoreConnector(datasource, dbSchemaValidation, applicationContextBean);
-
- StoreUtil.run(false, false, runnable);
-
- } catch (Exception e){
- StoreUtil.errorDialog("Error trying to connect to datasource", "An error occurred while connecting to the datasource." +
- "Please refer to the error log.");
- logger.error(e);
- throw new RuntimeException(e);
- }
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(StoreUtil.getShell());
+ dialog.run(false, true, new CdmDataStoreConnector(datasource, dbSchemaValidation, applicationContextBean));
+ } catch (InvocationTargetException e) {
+ StoreUtil.error(CdmStore.class, e);
+ } catch (InterruptedException e) {
+ StoreUtil.error(CdmStore.class, e);
+ }
+
}
/**
* Closes the current application context
+ *
+ * @param monitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
*/
public static void close(IProgressMonitor monitor){
- notifyContextAboutToStop(monitor);
- if(isActive() && StoreUtil.closeAll()){
- notifyContextStop(monitor);
- instance.getApplicationController().close();
- instance.isConnected = false;
- cdmDatasource = null;
-
+ getContextManager().notifyContextAboutToStop(monitor);
+ if((monitor == null || (!monitor.isCanceled()) && isActive() && StoreUtil.closeAll())){
+ getContextManager().notifyContextStop(monitor);
+ if(instance.getApplicationController() != null){
+ instance.getApplicationController().close();
+ }
+ instance.close();
}
}
- /**
- *
- */
- private CdmStore(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, Resource applicationContextBean, eu.etaxonomy.cdm.common.IProgressMonitor progressMonitor) {
- try {
- // this should be more modulized
- applicationController = CdmApplicationController.NewInstance(applicationContextBean, dataSource, dbSchemaValidation, false, progressMonitor);
- //
- isConnected = true;
-
- cdmDatasource = dataSource;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ private void close() {
+ isConnected = false;
+ cdmDatasource = null;
+ }
+
+ private static void setInstance(CdmApplicationController applicationController, ICdmDataSource dataSource){
+ instance = new CdmStore(applicationController, dataSource);
+ }
+
+ private CdmStore(CdmApplicationController applicationController, ICdmDataSource dataSource){
+ this.applicationController = applicationController;
+ this.cdmDatasource = dataSource;
+ isConnected = true;
}
/**
try{
return applicationController;
}catch(Exception e){
- logger.error("Exception thrown", e);
+ StoreUtil.error(CdmStore.class, e);
}
return null;
}
+ /**
+ * <p>getCurrentApplicationController</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.application.CdmApplicationController} object.
+ */
public static CdmApplicationController getCurrentApplicationController(){
- return getDefault().getApplicationController();
+ if(getDefault() != null){
+ return getDefault().getApplicationController();
+ }
+ return null;
}
/*
*/
/**
- * Creates a new conversation, binds resources to the conversation and
+ * Creates a new conversation, binds resources to the conversation and
* start a transaction for this conversation.
- *
- * @return
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
public static ConversationHolder createConversation() {
- ConversationHolder conversation = getDefault().getApplicationController().NewConversation();
+ ConversationHolder conversation = getCurrentApplicationController().NewConversation();
conversation.startTransaction();
return conversation;
* EXPOSING SERVICES
*/
- public static ITaxonService getTaxonService(){ return getDefault().getApplicationController().getTaxonService();}
+ /**
+ * <p>getTaxonService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.ITaxonService} object.
+ */
+ public static ITaxonService getTaxonService(){ return getCurrentApplicationController().getTaxonService();}
- public static ITaxonTreeService getTaxonTreeService() { return getDefault().getApplicationController().getTaxonTreeService();}
+ /**
+ * <p>getTaxonTreeService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.ITaxonTreeService} object.
+ */
+ public static IClassificationService getClassificationService() { return getCurrentApplicationController().getClassificationService();}
- public static ITaxonNodeService getTaxonNodeService() { return getDefault().getApplicationController().getTaxonNodeService();}
+ /**
+ * <p>getTaxonNodeService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.ITaxonNodeService} object.
+ */
+ public static ITaxonNodeService getTaxonNodeService() { return getCurrentApplicationController().getTaxonNodeService();}
- public static INameService getNameService(){ return getDefault().getApplicationController().getNameService();}
+ /**
+ * <p>getNameService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.INameService} object.
+ */
+ public static INameService getNameService(){ return getCurrentApplicationController().getNameService();}
- public static IReferenceService getReferenceService(){ return getDefault().getApplicationController().getReferenceService();}
+ /**
+ * <p>getReferenceService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IReferenceService} object.
+ */
+ public static IReferenceService getReferenceService(){ return getCurrentApplicationController().getReferenceService();}
- public static ILocationService getLocationService(){ return getDefault().getApplicationController().getLocationService();}
+ /**
+ * <p>getLocationService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.ILocationService} object.
+ */
+ public static ILocationService getLocationService(){ return getCurrentApplicationController().getLocationService();}
- public static ProviderManager getAuthenticationManager() { return getDefault().getApplicationController().getAuthenticationManager();}
+ /**
+ * <p>getAuthenticationManager</p>
+ *
+ * @return a {@link org.springframework.security.authentication.ProviderManager} object.
+ */
+ public static ProviderManager getAuthenticationManager() { return getCurrentApplicationController().getAuthenticationManager();}
- public static IUserService getUserService() { return getDefault().getApplicationController().getUserService(); }
+ /**
+ * <p>getUserService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IUserService} object.
+ */
+ public static IUserService getUserService() { return getCurrentApplicationController().getUserService(); }
- public static ICommonService getCommonService() { return getDefault().getApplicationController().getCommonService(); }
+ /**
+ * <p>getCommonService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.ICommonService} object.
+ */
+ public static ICommonService getCommonService() { return getCurrentApplicationController().getCommonService(); }
- public static IAgentService getAgentService() { return getDefault().getApplicationController().getAgentService(); }
+ /**
+ * <p>getAgentService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IAgentService} object.
+ */
+ public static IAgentService getAgentService() { return getCurrentApplicationController().getAgentService(); }
- public static ITermService getTermService() { return getDefault().getApplicationController().getTermService(); }
+ /**
+ * <p>getTermService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.ITermService} object.
+ */
+ public static ITermService getTermService() { return getCurrentApplicationController() != null ? getCurrentApplicationController().getTermService() : null; }
- public static IVocabularyService getVocabularyService() { return getDefault().getApplicationController().getVocabularyService(); }
+ /**
+ * <p>getVocabularyService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IVocabularyService} object.
+ */
+ public static IVocabularyService getVocabularyService() { return getCurrentApplicationController().getVocabularyService(); }
- public static IMediaService getMediaService() { return getDefault().getApplicationController().getMediaService(); }
+ /**
+ * <p>getMediaService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IMediaService} object.
+ */
+ public static IMediaService getMediaService() { return getCurrentApplicationController().getMediaService(); }
- public static IOccurrenceService getOccurrenceService() { return getDefault().getApplicationController().getOccurrenceService(); }
+ /**
+ * <p>getOccurrenceService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IOccurrenceService} object.
+ */
+ public static IOccurrenceService getOccurrenceService() { return getCurrentApplicationController().getOccurrenceService(); }
- public static IFeatureTreeService getFeatureTreeService() { return getDefault().getApplicationController().getFeatureTreeService(); }
+ /**
+ * <p>getFeatureTreeService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IFeatureTreeService} object.
+ */
+ public static IFeatureTreeService getFeatureTreeService() { return getCurrentApplicationController().getFeatureTreeService(); }
- public static IFeatureNodeService getFeatureNodeService() { return getDefault().getApplicationController().getFeatureNodeService(); }
+ /**
+ * <p>getFeatureNodeService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.IFeatureNodeService} object.
+ */
+ public static IFeatureNodeService getFeatureNodeService() { return getCurrentApplicationController().getFeatureNodeService(); }
+
+ /**
+ * <p>getCollectionService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.service.ICollectionService} object.
+ */
+ public static ICollectionService getCollectionService() { return getCurrentApplicationController().getCollectionService(); }
+ /**
+ * <p>getGeoService</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.ext.geo.IEditGeoService} object.
+ */
public static IEditGeoService getGeoService(){
- return (IEditGeoService) getDefault().getApplicationController().getBean("editGeoService");
+ return (IEditGeoService) getCurrentApplicationController().getBean("editGeoService");
}
-
+
/*
* METHODS TO FIND ENTITIES
*/
/**
- *
- * @param configurator
- * @return
+ * <p>findNames</p>
+ *
+ * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
+ * @return a {@link java.util.List} object.
*/
public static List<TaxonNameBase> findNames(IIdentifiableEntityServiceConfigurator configurator){
// TODO we want to use IIdentifiableEntityServiceConfigurator for all find methods
}
/**
- *
- * @param configurator
- * @return
+ * <p>findTaxaAndNames</p>
+ *
+ * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator} object.
+ * @return a {@link java.util.List} object.
*/
public static List<IdentifiableEntity> findTaxaAndNames(ITaxonServiceConfigurator configurator){
return getTaxonService().findTaxaAndNames(configurator).getRecords();
}
/**
- *
- * @param configurator
- * @return
+ * <p>findReferences</p>
+ *
+ * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
+ * @return a {@link java.util.List} object.
*/
- public static List<ReferenceBase> findReferences(IIdentifiableEntityServiceConfigurator configurator){
+ public static List<Reference> findReferences(IIdentifiableEntityServiceConfigurator configurator){
// TODO we want to use IIdentifiableEntityServiceConfigurator for all find methods
// unfortunately this is not consistently implemented in the library.
// FIXME use proper method once it is implemented in the library
}
/**
- *
- * @param configurator
- * @return
+ * <p>findAgents</p>
+ *
+ * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
+ * @return a {@link java.util.List} object.
*/
public static List<AgentBase> findAgents(IIdentifiableEntityServiceConfigurator configurator){
// TODO we want to use IIdentifiableEntityServiceConfigurator for all find methods
return getAgentService().findByTitle(null, titleSearchString, null, null, null, null, null, null).getRecords();
}
+ /**
+ * <p>findTeamOrPersons</p>
+ *
+ * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
+ * @return a {@link java.util.List} object.
+ */
public static List<TeamOrPersonBase> findTeamOrPersons(IIdentifiableEntityServiceConfigurator configurator){
// TODO move this to cdmlib
List<TeamOrPersonBase> result = new ArrayList<TeamOrPersonBase>();
return result;
}
+ /**
+ * <p>findOccurrences</p>
+ *
+ * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
+ * @return a {@link java.util.List} object.
+ */
public static List<SpecimenOrObservationBase> findOccurrences(IIdentifiableEntityServiceConfigurator configurator){
// TODO we want to use IIdentifiableEntityServiceConfigurator for all find methods
// unfortunately this is not consistently implemented in the library.
* LANGUAGE
*/
- /**
- * @return
+ /**
+ * <p>getDefaultLanguage</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.model.common.Language} object.
*/
public static Language getDefaultLanguage(){
if(getDefault().getLanguage() == null){
return getDefault().getLanguage();
}
+ /**
+ * <p>setDefaultLanguage</p>
+ *
+ * @param language a {@link eu.etaxonomy.cdm.model.common.Language} object.
+ */
public static void setDefaultLanguage(Language language){
getDefault().setLanguage(language);
}
*/
/**
- *
+ * <p>Getter for the field <code>loginManager</code>.</p>
+ *
+ * @return a {@link eu.etaxonomy.taxeditor.store.LoginManager} object.
*/
public static LoginManager getLoginManager(){
if(loginManager == null){
return loginManager;
}
- private int authenticate(){
-
- LoginDialog loginDialog = new LoginDialog(StoreUtil.getShell());
- return loginDialog.open();
+ /**
+ * <p>Getter for the field <code>contextManager</code>.</p>
+ *
+ * @return a {@link eu.etaxonomy.taxeditor.store.ContextManager} object.
+ */
+ public static synchronized ContextManager getContextManager(){
+ if(contextManager == null){
+ contextManager = new ContextManager();
+ }
+ return contextManager;
}
/*
*/
/**
- *
+ * <p>Getter for the field <code>importHandler</code>.</p>
+ *
+ * @return a {@link eu.etaxonomy.taxeditor.io.ImportHandler} object.
*/
public static synchronized ImportHandler getImportHandler(){
if(importHandler == null){
- importHandler = ImportHandler.NewInstance(getDefault().getApplicationController());
+ importHandler = ImportHandler.NewInstance(getCurrentApplicationController());
}
return importHandler;
}
/**
- *
- * @return
+ * <p>Getter for the field <code>exportHandler</code>.</p>
+ *
+ * @return a {@link eu.etaxonomy.taxeditor.io.ExportHandler} object.
*/
public static synchronized ExportHandler getExportHandler(){
if(exportHandler == null){
- exportHandler = ExportHandler.NewInstance(getDefault().getApplicationController());
+ exportHandler = ExportHandler.NewInstance(getCurrentApplicationController());
}
return exportHandler;
}
/**
* Whether this CdmStore is currently connected to a datasource
- * @return
+ *
+ * @return a boolean.
*/
public static boolean isActive(){
return instance != null && instance.isConnected;
}
- public static void addContextListener(IContextListener listener){
- contextListeners.add(listener);
- }
-
- public static void removeContextListener(IContextListener listener) {
- contextListeners.remove(listener);
- }
-
- public static void notifyContextStart(IProgressMonitor monitor) {
- logger.info("Notifying context listeners, that the context has started.");
-
- instance.authenticate();
-
-
- for(Object listener : contextListeners.getListeners()){
- ((IContextListener) listener).onContextEvent(EventType.START, monitor);
- }
- }
-
- public static void notifyContextAboutToStop(IProgressMonitor monitor){
- for(Object listener : contextListeners.getListeners()){
- ((IContextListener) listener).onContextEvent(EventType.ABOUT_TO_STOP, monitor);
- }
- }
-
- public static void notifyContextStop(IProgressMonitor monitor) {
- logger.warn("Application event occured");
-
- for(Object listener : contextListeners.getListeners()){
- ((IContextListener) listener).onContextEvent(EventType.STOP, monitor);
- }
- }
-
+ /**
+ * <p>getDataSource</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
+ */
public static ICdmDataSource getDataSource(){
if(isActive()){
- return cdmDatasource;
+ return instance.getDatasource();
}
return null;
}
+ /**
+ * @return
+ */
+ private ICdmDataSource getDatasource() {
+ return cdmDatasource;
+ }
+
+ /**
+ * <p>createDefaultClassification</p>
+ *
+ * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ */
public static void createDefaultClassification(ConversationHolder conversation){
- TaxonomicTree defaultClassification = TaxonomicTree.NewInstance("My Classification");
- getTaxonTreeService().saveOrUpdate(defaultClassification);
+ Classification defaultClassification = Classification.NewInstance("My Classification");
+ getClassificationService().saveOrUpdate(defaultClassification);
conversation.commit(true);
}
}