Project

General

Profile

« Previous | Next » 

Revision 337563aa

Added by Andreas Müller over 6 years ago

cleanup

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/api/application/CdmIoApplicationController.java
16 16

  
17 17

  
18 18
	public static final String DEFAULT_APPLICATION_CONTEXT_RESOURCE = "/eu/etaxonomy/cdm/defaultIoApplicationContext.xml";
19
	
20
	
19

  
20

  
21 21
	public static CdmIoApplicationController NewInstance() throws DataSourceNotFoundException {
22 22
		return CdmIoApplicationController.NewInstance(getDefaultDatasource(), defaultDbSchemaValidation, false);
23 23
	}
24
	
24

  
25 25
	public static CdmIoApplicationController NewInstance(DbSchemaValidation dbSchemaValidation) throws DataSourceNotFoundException {
26 26
		return CdmIoApplicationController.NewInstance(getDefaultDatasource(), dbSchemaValidation, false);
27 27
	}
28
	
28

  
29 29
	/**
30 30
	 * Constructor, opens an spring ApplicationContext by using the according data source and the
31 31
	 * default database schema validation type
......
35 35
		return CdmIoApplicationController.NewInstance(dataSource, defaultDbSchemaValidation, false);
36 36
	}
37 37

  
38
	
38

  
39 39
	public static CdmIoApplicationController NewInstance(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation) {
40 40
		return CdmIoApplicationController.NewInstance(dataSource, dbSchemaValidation, false);
41 41
	}
......
65 65
		super(applicationContextResource, dataSource, dbSchemaValidation, omitTermLoading, progressMonitor, null);
66 66
		
67 67
	}
68
	
68

  
69 69
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmDefaultIOBase.java
77 77
	public ICdmRepository getCdmAppController() {
78 78
		return this.cdmApp;
79 79
	}
80

  
81 80
	/**
82
	 * @param cdmApp
83
	 *            the cdmApp to set
81
	 * @see #getCdmAppController()
84 82
	 */
85 83
	public void setCdmAppController(ICdmRepository cdmApp) {
86 84
		this.cdmApp = cdmApp;
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/IIoConfigurator.java
1 1
/**
2 2
* Copyright (C) 2008 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5 5
*/
6 6

  
......
29 29
	 * @return String representing the source for the io
30 30
	 */
31 31
	public String getSourceNameString();
32
	
32

  
33 33

  
34 34
	/**
35 35
	 * A String representation of the destination may it be an import destination and therefore a CDM (e.g. CDM Cichorieae Database)
......
37 37
	 * @return
38 38
	 */
39 39
	public String getDestinationNameString();
40
	
41
	
40

  
41

  
42 42
	/**
43 43
	 * Returns the CdmApplicationController
44 44
	 * @return
45 45
	 */
46 46
	public ICdmRepository getCdmAppController();
47 47

  
48
	
48

  
49 49
	/**
50 50
	 * Sets the CdmApplicationController
51 51
	 * @param cdmApp the cdmApp to set
......
61 61

  
62 62
	/**
63 63
	 * Get the way how the CDM schema is validated
64
	 * For exports values that delete the source (CREATE, CREATE_DROP) are not allowed and may throw an 
64
	 * For exports values that delete the source (CREATE, CREATE_DROP) are not allowed and may throw an
65 65
	 * Exception in the further run
66 66
	 * @see eu.etaxonomy.cdm.database.DbSchemaValidation
67 67
	 * @param dbSchemaValidation
68 68
	 */
69 69
	public void setDbSchemaValidation(DbSchemaValidation dbSchemaValidation);
70 70

  
71
	
71

  
72 72
	/**
73 73
	 * Returns the progress monitor.
74 74
	 * @return
75 75
	 */
76 76
	public IProgressMonitor getProgressMonitor();
77
	
77

  
78 78
	/**
79 79
	 * Sets the progress monitor.
80 80
	 * @see #getProgressMonitor()
......
86 86
	 * Returns the observers for this import/export
87 87
	 * @return
88 88
	 */
89
	public Set<IIoObserver> getObservers();
89
	@Override
90
    public Set<IIoObserver> getObservers();
90 91

  
91 92
	/**
92 93
	 * Sets the observers for this import/export
93 94
	 * @param observers
94 95
	 */
95 96
	public void setObservers(Set<IIoObserver> observers);
96
	
97

  
97 98
	public UsernamePasswordAuthenticationToken getAuthenticationToken();
98 99

  
99 100
	public void setAuthenticationToken(UsernamePasswordAuthenticationToken token);
100
	
101

  
101 102
	public void setAuthentication(String login, String password);
102
	
103

  
103 104
	/**
104 105
	 * Creates the UsernamePasswordAuthenticationToken for the default admin.
105
	 * 
106
	 *
106 107
	 * @see Configuration#adminLogin
107 108
	 * @see Configuration#adminPassword
108 109
	 */
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/IoConfiguratorBase.java
42 42

  
43 43
//	private Set<IIoObserver> observers = new HashSet<>();
44 44

  
45
	//etc
45

  
46
    //etc
46 47
	private IProgressMonitor progressMonitor;
47 48

  
48 49

  
......
117 118
		this.authenticationToken = token;
118 119
	}
119 120

  
120
	/* (non-Javadoc)
121
	 * @see eu.etaxonomy.cdm.io.common.IIoConfigurator#authenticateAsDefaultAdmin()
122
	 */
123 121
	@Override
124 122
	public void authenticateAsDefaultAdmin() {
125 123
		setAuthentication(Configuration.adminLogin, Configuration.adminPassword);
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcTaxonCsv2CdmTaxonRelationConverter.java
58 58
        if (!config.isDoSplitRelationshipImport()){
59 59
            return null;
60 60
        }else{
61
            return new DwcTaxonStreamItem2CdmTaxonConverter(state, true);  //the converter also is implementing the ItemFilter interfacem, this way we guarantee that the evaluation if the item is a synonym, lower or higher taxon is the same during taxon creation and relationship creation
61
            return new DwcTaxonStreamItem2CdmTaxonConverter<>(state, true);  //the converter also is implementing the ItemFilter interfacem, this way we guarantee that the evaluation if the item is a synonym, lower or higher taxon is the same during taxon creation and relationship creation
62 62
        }
63 63
    }
64 64

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcTaxonStreamItem2CdmTaxonConverter.java
140 140
		MappedCdmBase<Reference> sec = getNameAccordingTo(csvTaxonRecord, resultList);
141 141

  
142 142
		if (sec == null && state.getConfig().isUseSourceReferenceAsSec()){
143
			sec = new MappedCdmBase<Reference>(state.getTransactionalSourceReference());
143
			sec = new MappedCdmBase<>(state.getTransactionalSourceReference());
144 144
		}
145 145
		if (sec != null){
146 146
			taxonBase.setSec(sec.getCdmBase());
......
252 252
			taxon.addSource(OriginalSourceType.Import, id, idNamespace, ref, null);
253 253
		}
254 254

  
255

  
256

  
257 255
	}
258 256

  
259 257

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaDataImportBase.java
1 1
/**
2 2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
15 15
import eu.etaxonomy.cdm.io.stream.StreamImportBase;
16 16

  
17 17
/**
18
 * 
18
 *
19 19
 * @author a.mueller
20 20
 *
21 21
 */
22 22
public abstract class DwcaDataImportBase<CONFIG extends DwcaDataImportConfiguratorBase<STATE>, STATE extends DwcaDataImportStateBase<CONFIG>> extends StreamImportBase<CONFIG, STATE>{
23
	@SuppressWarnings("unused")
23

  
24
    private static final long serialVersionUID = 8816075241549849925L;
25
    @SuppressWarnings("unused")
24 26
	private static final Logger logger = Logger.getLogger(DwcaDataImportBase.class);
25 27

  
26
	
28

  
27 29
	@Override
28 30
	protected void finalizeStream(IItemStream itemStream, STATE state) {
29 31
		fireWarningEvent("Stream finished", itemStream.getStreamLocation(), 0);
......
33 35
			}
34 36
		}
35 37
	}
36
	
38

  
37 39
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaDataImportConfiguratorBase.java
23 23
 * @author a.mueller
24 24
 * @created 04.06.2013
25 25
 */
26
public abstract class DwcaDataImportConfiguratorBase<STATE extends DwcaDataImportStateBase> extends StreamImportConfiguratorBase<STATE, URI> implements IImportConfigurator {
26
public abstract class DwcaDataImportConfiguratorBase<STATE extends DwcaDataImportStateBase>
27
        extends StreamImportConfiguratorBase<STATE, URI> implements IImportConfigurator {
27 28
	@SuppressWarnings("unused")
28 29
	private static final Logger logger = Logger.getLogger(DwcaDataImportConfiguratorBase.class);
29 30
//	private static IInputTransformer defaultTransformer = new DwcaImportTransformer();
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaDataImportStateBase.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
18 18
 * @author a.mueller
19 19
 * @created 23.11.2011
20 20
 */
21
public abstract class DwcaDataImportStateBase<CONFIG extends DwcaDataImportConfiguratorBase> extends StreamImportStateBase<CONFIG, StreamImportBase>{
21
public abstract class DwcaDataImportStateBase<CONFIG extends DwcaDataImportConfiguratorBase>
22
        extends StreamImportStateBase<CONFIG, StreamImportBase>{
22 23
	@SuppressWarnings("unused")
23 24
	private static final Logger logger = Logger.getLogger(DwcaDataImportStateBase.class);
24 25

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaImport.java
56 56
	protected IPartitionableConverter<StreamItem,IReader<CdmBase>, String> getConverter(TermUri namespace, DwcaImportState state) {
57 57
		if (namespace.equals(TermUri.DWC_TAXON)){
58 58
			if (state.getConfig().isDoTaxa() && ! state.isTaxaCreated()){
59
				return new DwcTaxonStreamItem2CdmTaxonConverter(state);
59
				return new DwcTaxonStreamItem2CdmTaxonConverter<>(state);
60 60
			}else{
61 61
				return new DwcTaxonCsv2CdmTaxonRelationConverter(state);
62 62
			}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaImportConfigurator.java
22 22
 * @author a.mueller
23 23
 * @created 05.05.2011
24 24
 */
25
public class DwcaImportConfigurator extends DwcaDataImportConfiguratorBase<DwcaImportState> implements IImportConfigurator {
25
public class DwcaImportConfigurator
26
        extends DwcaDataImportConfiguratorBase<DwcaImportState>
27
        implements IImportConfigurator {
26 28

  
27 29
    private static final long serialVersionUID = 6932718596034946336L;
28 30
    @SuppressWarnings("unused")
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaImportState.java
22 22
	public DwcaImportState(DwcaImportConfigurator config) {
23 23
		super(config);
24 24
	}
25

  
26

  
27 25
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaImportTransformer.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
22 22
 * @created 05.05.2011
23 23
 */
24 24
public final class DwcaImportTransformer extends InputTransformerBase {
25
	@SuppressWarnings("unused")
25
    private static final long serialVersionUID = 3204045957159056826L;
26

  
27
    @SuppressWarnings("unused")
26 28
	private static final Logger logger = Logger.getLogger(DwcaImportTransformer.class);
27 29

  
28 30
	private static final UUID uuidFeatureBiology = UUID.fromString("daf92173-a262-49f1-9a45-923941d9c557");
29
	
31

  
30 32
	/* (non-Javadoc)
31 33
	 * @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getFeatureByKey(java.lang.String)
32 34
	 */
......
51 53
		}else if (key.equalsIgnoreCase("uses")){
52 54
			return Feature.USES();
53 55
		}
54
		
55 56

  
56 57

  
57
		
58

  
59

  
58 60
		return null;
59 61
	}
60 62

  
61
	/* (non-Javadoc)
62
	 * @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getFeatureUuid(java.lang.String)
63
	 */
64 63
	@Override
65 64
	public UUID getFeatureUuid(String key) throws UndefinedTransformerMethodException {
66 65
		if (key == null){
......
79 78
//		threats
80 79
//		cyclicity
81 80
//		management
82
//		
81
//
83 82
//		evolution
84 83
//		genetics
85 84
//		growth
......
96 95
//		taxon_biology
97 96
//		trophic_strategy
98 97

  
99
		
98

  
100 99
		return null;
101 100
	}
102
	
103
	
104 101

  
105
	
106
	
107
	
102

  
103

  
104

  
105

  
106

  
108 107
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaZipToStreamConverter.java
68 68
	);
69 69

  
70 70
	private final URI dwcaZip;
71
	private final Map<String, DwcaMetaDataRecord> metaRecords = new HashMap<String, DwcaMetaDataRecord>();
71
	private final Map<String, DwcaMetaDataRecord> metaRecords = new HashMap<>();
72 72
	private Archive archive;
73 73

  
74 74
/// ******************** FACTORY ********************************/
75 75

  
76
	public static DwcaZipToStreamConverter NewInstance(URI dwcaZip){
76
	public static DwcaZipToStreamConverter<DwcaImportState> NewInstance(URI dwcaZip){
77 77
		return new DwcaZipToStreamConverter(dwcaZip);
78 78
	}
79 79

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/ListReader.java
30 30
	 * @param list
31 31
	 */
32 32
	public ListReader(List<TYPE> list) {
33
		this.list = new ArrayList<TYPE>();
33
		this.list = new ArrayList<>();
34 34
		this.list.addAll(list);
35 35
	}
36 36

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/LookAheadStream.java
24 24
	@SuppressWarnings("unused")
25 25
	private static final Logger logger = Logger.getLogger(LookAheadStream.class);
26 26

  
27
	private final Queue<ITEM> fifo = new LinkedBlockingQueue<ITEM>();
27
	private final Queue<ITEM> fifo = new LinkedBlockingQueue<>();
28 28

  
29 29
	private final INamespaceReader<ITEM> stream;
30 30

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/MappedCdmBase.java
1 1
/**
2 2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
17 17
 *
18 18
 */
19 19
public class MappedCdmBase<CDMBASE extends CdmBase> {
20
	
21
	
20

  
21

  
22 22
	private String namespace;
23 23
	private String sourceId;
24
	
24

  
25 25
	private CDMBASE cdmBase;
26 26

  
27 27
	public MappedCdmBase(String namespace, String sourceId, CDMBASE cdmBase) {
......
30 30
		this.sourceId = sourceId;
31 31
		this.cdmBase = cdmBase;
32 32
	}
33
	
33

  
34 34
	public MappedCdmBase(TermUri termUri, String sourceId, CDMBASE cdmBase) {
35 35
		super();
36 36
		this.namespace = termUri.toString();
37 37
		this.sourceId = sourceId;
38 38
		this.cdmBase = cdmBase;
39 39
	}
40
	
40

  
41 41
	public MappedCdmBase(String sourceId, CDMBASE cdmBase) {
42 42
		super();
43 43
		this.namespace = null;
44 44
		this.sourceId = sourceId;
45 45
		this.cdmBase = cdmBase;
46 46
	}
47
	
47

  
48 48
	public MappedCdmBase(CDMBASE cdmBase) {
49 49
		super();
50 50
		this.namespace = null;
......
63 63
	public CDMBASE getCdmBase() {
64 64
		return cdmBase;
65 65
	}
66
	
66

  
67 67
	public boolean isMappable(){
68 68
		return (this.namespace != null && this.sourceId != null && this.cdmBase != null);
69 69
	}
70
	
71
	public String toString(){
70

  
71
	@Override
72
    public String toString(){
72 73
		String result = CdmUtils.concat("@", new String[]{namespace, sourceId, cdmBase.toString()});
73 74
		return result;
74 75
	}
75
	
76
	
76

  
77

  
77 78
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/PartitionableConverterBase.java
126 126

  
127 127
	@Override
128 128
    public Map<String, Set<String>> getPartitionForeignKeys(IReader<StreamItem> instream) {
129
		Map<String, Set<String>> result = new HashMap<String, Set<String>>();
129
		Map<String, Set<String>> result = new HashMap<>();
130 130

  
131 131
		while (instream.hasNext()){
132 132
			StreamItem next = instream.read();
......
169 169
	}
170 170

  
171 171

  
172
	protected <T extends TaxonBase> T getTaxonBase(String id, StreamItem item, Class<T> clazz, STATE state) {
172
	protected <T extends TaxonBase<?>> T getTaxonBase(String id, StreamItem item, Class<T> clazz, STATE state) {
173 173
		if (clazz == null){
174
			clazz = (Class)TaxonBase.class;
174
			clazz = (Class<T>)TaxonBase.class;
175 175
		}
176 176
		List<T> taxonList = state.get(TermUri.DWC_TAXON.toString(), id, clazz);
177 177
		if (taxonList.size() > 1){
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/StreamPartitioner.java
38 38
	private final StreamImportStateBase<StreamImportConfiguratorBase, StreamImportBase> state;
39 39
	private ConcatenatingReader<MappedCdmBase<? extends CdmBase>> outStream;
40 40

  
41
	public StreamPartitioner(INamespaceReader<ITEM> input, IPartitionableConverter converter, StreamImportStateBase state, Integer size){
42
		 this.inStream = new LookAheadStream<ITEM>(input);
41
	public StreamPartitioner(INamespaceReader<ITEM> input, IPartitionableConverter converter,
42
	        StreamImportStateBase<StreamImportConfiguratorBase, StreamImportBase> state, Integer size){
43
		 this.inStream = new LookAheadStream<>(input);
43 44
		 this.converter = converter;
44 45
		 this.partitionSize = size;
45 46
		 this.state = state;
......
73 74
	}
74 75

  
75 76
	private void handleNextPartition(){
76
	    List<ITEM> lookaheadArray = new ArrayList<ITEM>();
77
	    List<ITEM> lookaheadArray = new ArrayList<>();
77 78
		while (this.inStream.hasNextLookAhead(partitionSize)){
78 79
			lookaheadArray.add(this.inStream.readLookAhead());
79 80
		}
80 81

  
81
		IReader<ITEM> lookaheadStream = new ListReader<ITEM>(lookaheadArray);
82
		IReader<ITEM> lookaheadStream = new ListReader<>(lookaheadArray);
82 83

  
83 84
		Map<String, Set<String>> foreignKeys = converter.getPartitionForeignKeys(lookaheadStream);
84 85
		IImportMapping mapping = state.getMapping();
......
118 119
			if (cdmBase.isInstanceOf(IdentifiableEntity.class)){
119 120
			    Set<String> requiredSourceNamespaces = converter.requiredSourceNamespaces();
120 121
				if (requiredSourceNamespaces.contains(item.getNamespace())){
121
					if (item.getCdmBase().isInstanceOf(IdentifiableEntity.class)) {
122
					    IdentifiableEntity identEntity = CdmBase.deproxy(item.getCdmBase(), IdentifiableEntity.class);
123
                        state.addRelatedObject(item.getNamespace(), item.getSourceId(), identEntity);
124
                    }else{
125

  
126
                    }
122
					state.addRelatedObject(item.getNamespace(), item.getSourceId(), item.getCdmBase());
127 123
				}
128 124
			}
129 125
		}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/stream/StreamImportBase.java
75 75

  
76 76
			ItemFilter<StreamItem> filter = partitionConverter.getItemFilter();
77 77
			IItemStream filteredStream = filter == null ? recordStream : new FilteredStream(recordStream, filter);
78
			StreamPartitioner<StreamItem> partitionStream = new StreamPartitioner<>(filteredStream,
78
			StreamPartitioner<StreamItem> partitionStream = new StreamPartitioner(filteredStream,
79 79
					partitionConverter, state, partitionSize);//   (csvStream, streamConverter,state 1000);
80 80

  
81 81
			int i = 1;
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/stream/StreamImportConfiguratorBase.java
91 91
	public boolean isUsePartitions() {
92 92
		return usePartitions;
93 93
	}
94

  
95 94
	public void setUsePartitions(boolean usePartitions) {
96 95
		this.usePartitions = usePartitions;
97 96
	}
......
99 98
	public void setDefaultPartitionSize(int defaultPartitionSize) {
100 99
		this.defaultPartitionSize = defaultPartitionSize;
101 100
	}
102

  
103 101
	public int getDefaultPartitionSize() {
104 102
		return defaultPartitionSize;
105 103
	}
......
107 105
	public IImportMapping.MappingType getMappingType() {
108 106
		return mappingType;
109 107
	}
110

  
111 108
	public void setMappingType(IImportMapping.MappingType mappingType) {
112 109
		this.mappingType = mappingType;
113 110
	}
......
123 120
	}
124 121

  
125 122

  
126
    /**
127
     * @return the databaseMappingFile
128
     */
129 123
    public String getDatabaseMappingFile() {
130 124
        return databaseMappingFile;
131 125
    }
132

  
133
    /**
134
     * @param databaseMappingFile the databaseMappingFile to set
135
     */
136 126
    public void setDatabaseMappingFile(String databaseMappingFile) {
137 127
        this.databaseMappingFile = databaseMappingFile;
138 128
    }
139 129

  
140 130

  
141
    /**
142
     * @return the stateUuid
143
     */
144 131
    public UUID getStateUuid() {
145 132
        return stateUuid;
146 133
    }
147
    /**
148
     * @param stateuuid
149
     */
150 134
    public void setStateUuid(UUID stateUuid) {
151 135
        this.stateUuid = stateUuid;
152 136
    }
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/CdmDataSource.java
16 16
import org.apache.log4j.Logger;
17 17
import org.hibernate.cache.internal.NoCachingRegionFactory;
18 18
import org.hibernate.cache.spi.RegionFactory;
19
import org.hibernate.cfg.Environment;
20 19
import org.springframework.beans.MutablePropertyValues;
21 20
import org.springframework.beans.factory.config.BeanDefinition;
22 21
import org.springframework.beans.factory.config.PropertiesFactoryBean;
......
168 167
		while (keys.hasMoreElements()){
169 168
			String key = (String)keys.nextElement();
170 169
			props.addPropertyValue(key, persistentProperties.getProperty(key));
171
			Properties a = Environment.getProperties();
170
//			Properties a = Environment.getProperties();
172 171
		}
173 172

  
174 173
		bd.setPropertyValues(props);
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
28 28
	 * @return BeanDefinition
29 29
	 */
30 30
	public BeanDefinition getDatasourceBean();
31
	
31

  
32 32
	/**
33 33
	 * @param hbm2dll
34 34
	 * @return BeanDefinition
35 35
	 */
36 36
	public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll);
37
	
37

  
38 38
	/**
39 39
	 * @param hbm2dll
40 40
	 * @param showSql
......
45 45
	public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Boolean registerSearchListener, Class<? extends RegionFactory> cacheProviderClass);
46 46

  
47 47

  
48
	
49 48
	/**
50 49
	 * @return
51 50
	 */
......
55 54
	 * @return
56 55
	 */
57 56
	public H2Mode getMode();
58
	
57

  
59 58
	public String getUsername();
60
	
59

  
61 60
	public String getPassword();
62
	
61

  
63 62
	public String getDatabase();
64
	
63

  
65 64
	public void setMode(H2Mode h2Mode);
66
	
65

  
67 66
	public void setUsername(String username);
68
	
67

  
69 68
	public void setPassword(String password);
70
	
69

  
71 70
	public void setDatabase(String database);
72
	
73
	
71

  
72

  
74 73
	/**
75
	 * Returns the database type of the data source. 
76
	 * @return the database type of the data source. 
74
	 * Returns the database type of the data source.
75
	 * @return the database type of the data source.
77 76
	 * <code>null</code> if the bean or the driver class property does not exist or the driver class is unknown.
78 77
	 */
79 78
	public DatabaseTypeEnum getDatabaseType();
80 79
	/**
81 80
	 * Tests, if a database connection can be established.
82 81
	 * @return true if test was successful, false otherwise
83
	 * @throws ClassNotFoundException 
84
	 * @throws SQLException 
85
	 * @throws Exception 
82
	 * @throws ClassNotFoundException
83
	 * @throws SQLException
84
	 * @throws Exception
86 85
	 */
87 86
	public boolean testConnection() throws ClassNotFoundException, SQLException;
88
	
87

  
89 88

  
90 89
	 /**
91 90
     * Executes a query and returns the ResultSet.
92 91
     * @return ResultSet for the query.
93
	 * @throws SQLException 
92
	 * @throws SQLException
94 93
     */
95 94
	public ResultSet executeQuery (String query) throws SQLException;
96
	
95

  
97 96
    /**
98 97
     * Executes an update
99 98
     * @return return code
100 99
     */
101 100
	public int executeUpdate (String sqlUpdate) throws SQLException;
102
	
101

  
103 102
	/**
104 103
	 * Starts a transaction for the given datasource.
105 104
	 */
106 105
	public void startTransaction();
107
	
106

  
108 107
	/**
109 108
	 * Commits the transaction for the given datasource.
110 109
	 * @return
111
	 * @throws SQLException 
110
	 * @throws SQLException
112 111
	 */
113 112
	public void commitTransaction() throws SQLException;
114
	
113

  
115 114
	/**
116 115
	 * Rolls the connection back.
117
	 * @throws SQLException 
116
	 * @throws SQLException
118 117
	 */
119 118
	public void rollback() throws SQLException;
120 119

  
......
123 122
	 * Returns the first value of the first row of a result set.<BR>
124 123
	 * If no row exists in the result set
125 124
	 * <code>null</code> is returned.
126
	 * 
125
	 *
127 126
	 * <strong>Caution</strong> This method opens a connection on first use. Subsequent calls will use the same connection.
128 127
	 * Please close the connection when not needed anymore with {@link ICdmDataSource#closeOpenConnections()}
129
	 * 
128
	 *
130 129
	 * @param query
131 130
	 * @return
132 131
	 * @throws SQLException
133 132
	 */
134
	public Object getSingleValue(String query) throws SQLException;	
135
	
133
	public Object getSingleValue(String query) throws SQLException;
134

  
136 135
	/**
137 136
	 * Returns {@link DatabaseMetaData} for <code>this</code> datasource.
138
	 * 
137
	 *
139 138
	 * <br>
140 139
	 * <br>
141 140
	 * <strong>Caution</strong> This method opens a connection that should be closed
142 141
	 * with {@link #closeOpenConnections()}
143
	 * 
142
	 *
144 143
	 * @return
145 144
	 */
146 145
	public DatabaseMetaData getMetaData();
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/WrappedCdmDataSource.java
396 396
			throw new RuntimeException(e);
397 397
		}
398 398
	}
399

  
399 400
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/initializer/AdvancedBeanInitializer.java
31 31
import org.hibernate.proxy.HibernateProxy;
32 32
import org.springframework.beans.factory.annotation.Autowired;
33 33

  
34
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
35 34
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
36 35
import eu.etaxonomy.cdm.model.common.CdmBase;
37 36
import eu.etaxonomy.cdm.persistence.dao.common.ICdmGenericDao;
38 37
import eu.etaxonomy.cdm.persistence.dao.hibernate.HibernateBeanInitializer;
38
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
39 39

  
40 40
/**
41 41
 * For now this is a test if we can improve performance for bean initializing
......
336 336
            //TODO check if other code works with audited data at all as we use HQL queries
337 337
            if (!node.hasWildcardToManySibling()){  //if wildcard sibling exists the lazies are already prepared there
338 338
                Collection<?> collection = (Collection<?>)propertyValue;
339
                //TODO it is difficult to find out if an envers collection is initiallized
340
                //but possiblie via reflection. If the "delegate" parameter is null it is not yet initialized.
339
                //TODO it is difficult to find out if an envers collection is initialized
340
                //but possibly via reflection. If the "delegate" parameter is null it is not yet initialized.
341 341
                //However, as we do not know if envers initialization works at all together with the AdvancedBeanInitializer
342 342
                //we initialize each collection immediately here by calling size()
343 343
                collection.size();  //initialize
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/CdmPostDataChangeObservableListener.java
35 35
 *
36 36
 * @author n.hoffmann
37 37
 * @created 24.03.2009
38
 * @version 1.0
39 38
 */
40 39
public class CdmPostDataChangeObservableListener implements
41 40
		  PostDeleteEventListener
......
69 68
	/**
70 69
	 * Observing objects
71 70
	 */
72
	private final Set<ICdmPostDataChangeObserver> observers = new HashSet<ICdmPostDataChangeObserver>();
71
	private final Set<ICdmPostDataChangeObserver> observers = new HashSet<>();
73 72

  
74 73

  
75 74
	/**
......
112 111
	public void delayedNotify(){
113 112
		if(delayed && changeEvents.size() > 0){
114 113
			Set<ICdmPostDataChangeObserver> modificationSaveObservers
115
						= new HashSet<ICdmPostDataChangeObserver>(observers);
114
						= new HashSet<>(observers);
116 115
			for( ICdmPostDataChangeObserver observer : modificationSaveObservers){
117 116
				observer.update(changeEvents);
118 117
			}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/PostMergeEntityListener.java
33 33
public class PostMergeEntityListener implements MergeEventListener {
34 34
    private static final long serialVersionUID = 1565797119368313987L;
35 35

  
36
    private static Map<Session, Set<CdmBase>> newEntitiesMap = new ConcurrentHashMap<Session, Set<CdmBase>>();
36
    private static Map<Session, Set<CdmBase>> newEntitiesMap = new ConcurrentHashMap<>();
37 37

  
38 38
    public static void addSession(Session session) {
39
        newEntitiesMap.put(session, new HashSet<CdmBase>());
39
        newEntitiesMap.put(session, new HashSet<>());
40 40
    }
41 41

  
42 42
    public static void removeSession(Session session) {
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationController.java
359 359
		init();
360 360
	}
361 361

  
362

  
363
	/*
364
	 * (non-Javadoc)
365
	 *
366
	 * @see java.lang.Object#finalize()
367
	 */
368 362
	@Override
369 363
	public void finalize(){
370 364
		close();
371 365
	}
372 366

  
373

  
374 367
	/**
375 368
	 * closes the application
376 369
	 */
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/MonitoredListableBeanFactory.java
34 34
	private IProgressMonitor currentMonitor;
35 35

  
36 36
	private static List<String> beansToMonitor = Arrays.asList("sessionFactory","defaultBeanInitializer","persistentTermInitializer");
37
	private final Set<String> alreadyMonitoredBeans = new HashSet<String>();
37
	private final Set<String> alreadyMonitoredBeans = new HashSet<>();
38 38

  
39 39
	public MonitoredListableBeanFactory(){
40 40
	}

Also available in: Unified diff