Revision 3ef2e1bd
Added by Andreas Müller over 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelTaxonRelationExport.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 |
*/ |
... | ... | |
25 | 25 |
import eu.etaxonomy.cdm.io.common.mapping.out.MethodMapper; |
26 | 26 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
27 | 27 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
28 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; |
|
29 | 28 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
30 | 29 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
31 | 30 |
|
... | ... | |
48 | 47 |
public BerlinModelTaxonRelationExport(){ |
49 | 48 |
super(); |
50 | 49 |
} |
51 |
|
|
50 |
|
|
52 | 51 |
/* (non-Javadoc) |
53 | 52 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
54 | 53 |
*/ |
... | ... | |
58 | 57 |
logger.warn("Checking for " + pluralString + " not yet implemented"); |
59 | 58 |
//result &= checkArticlesWithoutJournal(bmiConfig); |
60 | 59 |
//result &= checkPartOfJournal(bmiConfig); |
61 |
|
|
60 |
|
|
62 | 61 |
return result; |
63 | 62 |
} |
64 |
|
|
63 |
|
|
65 | 64 |
private CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> getMapping(){ |
66 | 65 |
String tableName = dbTableName; |
67 | 66 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = new CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer>(tableName); |
68 | 67 |
// mapping.addMapper(IdMapper.NewInstance("RelPTaxonId")); //is Identity column |
69 |
|
|
68 |
|
|
70 | 69 |
mapping.addMapper(MethodMapper.NewInstance("PTNameFk1", this.getClass(), "getPTNameFk1", standardMethodParameter, DbExportStateBase.class)); |
71 | 70 |
mapping.addMapper(MethodMapper.NewInstance("PTRefFk1", this.getClass(), "getPTRefFk1", standardMethodParameter, DbExportStateBase.class)); |
72 |
|
|
71 |
|
|
73 | 72 |
mapping.addMapper(MethodMapper.NewInstance("PTNameFk2", this.getClass(), "getPTNameFk2", standardMethodParameter, DbExportStateBase.class)); |
74 | 73 |
mapping.addMapper(MethodMapper.NewInstance("PTRefFk2", this.getClass(), "getPTRefFk2", standardMethodParameter, DbExportStateBase.class)); |
75 |
|
|
74 |
|
|
76 | 75 |
mapping.addMapper(MethodMapper.NewInstance("RelQualifierFk", this)); |
77 |
|
|
76 |
|
|
78 | 77 |
mapping.addMapper(DbObjectMapper.NewInstance("citation", "RelRefFk")); |
79 | 78 |
// mapping.addMapper(RefDetailMapper.NewInstance("citationMicroReference","citation", "FactRefDetailFk")); |
80 | 79 |
mapping.addMapper(CreatedAndNotesMapper.NewInstance()); |
81 | 80 |
|
82 | 81 |
return mapping; |
83 | 82 |
} |
84 |
|
|
85 |
protected void doInvoke(BerlinModelExportState state){ |
|
83 |
|
|
84 |
@Override |
|
85 |
protected void doInvoke(BerlinModelExportState state){ |
|
86 | 86 |
try{ |
87 | 87 |
logger.info("start make " + pluralString + " ..."); |
88 | 88 |
boolean success = true ; |
89 | 89 |
doDelete(state); |
90 |
|
|
90 |
|
|
91 | 91 |
TransactionStatus txStatus = startTransaction(true); |
92 |
|
|
92 |
|
|
93 | 93 |
List<RelationshipBase> list = getTaxonService().getAllRelationships(100000000, 0); |
94 |
|
|
94 |
|
|
95 | 95 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = getMapping(); |
96 | 96 |
mapping.initialize(state); |
97 |
|
|
97 |
|
|
98 | 98 |
int count = 0; |
99 | 99 |
for (RelationshipBase<?,?,?> rel : list){ |
100 | 100 |
if (rel.isInstanceOf(TaxonRelationship.class) || rel.isInstanceOf(SynonymRelationship.class)){ |
... | ... | |
116 | 116 |
} |
117 | 117 |
} |
118 | 118 |
|
119 |
|
|
119 |
|
|
120 | 120 |
protected boolean doDelete(BerlinModelExportState state){ |
121 | 121 |
BerlinModelExportConfigurator bmeConfig = state.getConfig(); |
122 |
|
|
122 |
|
|
123 | 123 |
String sql; |
124 | 124 |
Source destination = bmeConfig.getDestination(); |
125 | 125 |
//RelPTaxon |
... | ... | |
129 | 129 |
|
130 | 130 |
return true; |
131 | 131 |
} |
132 |
|
|
133 |
|
|
132 |
|
|
133 |
|
|
134 | 134 |
/* (non-Javadoc) |
135 | 135 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
136 | 136 |
*/ |
137 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
137 |
@Override |
|
138 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
138 | 139 |
return ! state.getConfig().isDoRelTaxa(); |
139 | 140 |
} |
140 |
|
|
141 |
|
|
141 | 142 |
//called by MethodMapper |
142 | 143 |
@SuppressWarnings("unused") |
143 | 144 |
private static Integer getRelQualifierFk(RelationshipBase<?, ?, ?> rel){ |
144 | 145 |
return BerlinModelTransformer.taxRelation2relPtQualifierFk(rel); |
145 | 146 |
} |
146 |
|
|
147 |
|
|
147 | 148 |
@SuppressWarnings("unused") |
148 | 149 |
private static Integer getPTNameFk1(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
149 | 150 |
return getObjectFk(rel, state, true, true); |
150 | 151 |
} |
151 |
|
|
152 |
|
|
152 | 153 |
@SuppressWarnings("unused") |
153 | 154 |
private static Integer getPTRefFk1(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
154 | 155 |
return getObjectFk(rel, state, false, true); |
155 | 156 |
} |
156 |
|
|
157 |
|
|
157 | 158 |
@SuppressWarnings("unused") |
158 | 159 |
private static Integer getPTNameFk2(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
159 | 160 |
return getObjectFk(rel, state, true, false); |
160 | 161 |
} |
161 |
|
|
162 |
|
|
162 | 163 |
@SuppressWarnings("unused") |
163 | 164 |
private static Integer getPTRefFk2(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
164 | 165 |
return getObjectFk(rel, state, false, false); |
... | ... | |
180 | 181 |
logger.warn("No taxon found for relationship: " + rel.toString()); |
181 | 182 |
return null; |
182 | 183 |
} |
183 |
|
|
184 |
|
|
184 |
|
|
185 |
|
|
185 | 186 |
/* (non-Javadoc) |
186 | 187 |
* @see eu.etaxonomy.cdm.io.berlinModel.out.BerlinModelExportBase#getStandardMethodParameter() |
187 | 188 |
*/ |
Also available in: Unified diff
ref #5974 Remove synonym relationships (not finished yet)