use of ch.interlis.ili2c.metamodel.Topic in project ili2db by claeis.
the class TransferToXtf method doit.
public void doit(int function, String datasource, IoxWriter iomFile, String sender, String[] exportParamModelnames, long[] basketSqlIds, Map<String, BasketStat> stat, CustomMapping customMapping1) throws ch.interlis.iox.IoxException, Ili2dbException {
this.basketStat = stat;
this.customMapping = customMapping1;
boolean referrs = false;
ignoreUnresolvedReferences = config.isSkipReferenceErrors();
if (!hasIliTidCol && writeIliTid) {
throw new Ili2dbException("TID export requires a " + DbNames.T_ILI_TID_COL + " column");
}
if (function != Config.FC_VALIDATE && iomFile instanceof ItfWriter) {
config.setValue(ch.interlis.iox_j.validator.Validator.CONFIG_DO_ITF_LINETABLES, ch.interlis.iox_j.validator.Validator.CONFIG_DO_ITF_LINETABLES_DO);
}
if (!config.isVer3_translation() || config.getIli1Translation() != null) {
languageFilter = new TranslateToTranslation(td, config);
}
if (config.isDisableRounding()) {
rounder = null;
} else {
rounder = new Rounder(td, config);
}
String srsAssignment = config.getSrsModelAssignment();
if (srsAssignment != null) {
crsFilter = TransferFromIli.getSrsMappingToOriginal(td, srsAssignment);
crsFilterToTarget = TransferFromIli.getSrsMappingToAlternate(td, srsAssignment);
}
if (config.getExportModels() != null) {
List<Model> exportModels = Ili2db.getModels(config.getExportModels(), td);
exportBaseModelFilter = new ReduceToBaseModel(exportModels, td, config);
}
if (config.isValidation()) {
ValidationConfig modelConfig = new ValidationConfig();
modelConfig.mergeIliMetaAttrs(td);
String configFilename = config.getValidConfigFile();
if (configFilename != null) {
try {
modelConfig.mergeConfigFile(new File(configFilename));
} catch (java.io.IOException e) {
EhiLogger.logError("failed to read validator config file <" + configFilename + ">");
}
}
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.AREA_OVERLAP_VALIDATION, config.isDisableAreaValidation() ? ValidationConfig.OFF : null);
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.DEFAULT_GEOMETRY_TYPE_VALIDATION, config.isSkipGeometryErrors() ? ValidationConfig.OFF : null);
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.ALLOW_ONLY_MULTIPLICITY_REDUCTION, config.isOnlyMultiplicityReduction() ? ValidationConfig.ON : null);
if (rounder == null) {
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.DISABLE_ROUNDING, ValidationConfig.TRUE);
}
IoxLogging errHandler = new ch.interlis.iox_j.logging.Log2EhiLogger();
LogEventFactory errFactory = new LogEventFactory();
errFactory.setDataSource(datasource);
if (iomFile instanceof Iligml10Writer || iomFile instanceof Iligml20Writer) {
String crsAuthority = config.getDefaultSrsAuthority();
String crsCode = config.getDefaultSrsCode();
if (crsAuthority != null && crsCode != null) {
if (function != Config.FC_VALIDATE) {
if (iomFile instanceof Iligml10Writer) {
((Iligml10Writer) iomFile).setDefaultCrs(crsAuthority + ":" + crsCode);
} else if (iomFile instanceof Iligml20Writer) {
((Iligml20Writer) iomFile).setDefaultCrs(crsAuthority + ":" + crsCode);
}
}
}
}
PipelinePool pipelinePool = new PipelinePool();
validator = new ch.interlis.iox_j.validator.Validator(td, modelConfig, errHandler, errFactory, pipelinePool, config);
}
StartTransferEvent startEvent = new StartTransferEvent();
startEvent.setSender(sender);
if (languageFilter != null) {
startEvent = (StartTransferEvent) languageFilter.filter(startEvent);
}
if (exportBaseModelFilter != null) {
startEvent = (StartTransferEvent) exportBaseModelFilter.filter(startEvent);
}
if (rounder != null) {
startEvent = (StartTransferEvent) rounder.filter(startEvent);
}
if (validator != null) {
validator.validate(startEvent);
}
if (function != Config.FC_VALIDATE) {
iomFile.write(startEvent);
}
if (basketSqlIds != null) {
for (long basketSqlId : basketSqlIds) {
StringBuilder basketXtfId = new StringBuilder();
Map<String, String> genericDomains = new HashMap<String, String>();
Topic topic = getTopicByBasketId(basketSqlId, basketXtfId, genericDomains);
if (config.getDomainAssignments() != null) {
EhiLogger.logState("domain assignments <" + config.getDomainAssignments() + ">");
genericDomains = Xtf24Reader.parseDomains(config.getDomainAssignments());
}
if (topic == null) {
throw new IoxException("no basketId " + basketSqlId + " in db");
} else {
if (basketXtfId.length() == 0) {
basketXtfId.append(basketSqlId);
}
referrs = referrs || doBasket(function, datasource, iomFile, topic, basketSqlId, basketXtfId.toString(), genericDomains);
}
}
} else {
// for all MODELs
for (String modelName : exportParamModelnames) {
Object mObj = td.getElement(Model.class, modelName);
if (mObj != null && (mObj instanceof Model) && !(suppressModel((Model) mObj))) {
Model model = (Model) mObj;
// for all TOPICs
Iterator topici = model.iterator();
while (topici.hasNext()) {
Object tObj = topici.next();
if (tObj instanceof Topic && !(suppressTopic((Topic) tObj))) {
Topic topic = (Topic) tObj;
String basketXtfId = topic.getScopedName();
Map<String, String> genericDomains = new HashMap<String, String>();
// if TOPIC has a stable BID?
if (topic.getBasketOid() != null) {
// if TOPIC has a stable BID, export only if there
// is exactly one entry in t_ilid2db_basket table
basketXtfId = getBasketSqlIdsFromTopic(topic.getScopedName(), genericDomains);
if (basketXtfId == null) {
// no basket found
continue;
}
}
if (config.getDomainAssignments() != null) {
EhiLogger.logState("domain assignments <" + config.getDomainAssignments() + ">");
genericDomains = Xtf24Reader.parseDomains(config.getDomainAssignments());
}
referrs = referrs || doBasket(function, datasource, iomFile, topic, null, basketXtfId, genericDomains);
}
}
}
}
}
if (referrs) {
throw new IoxException("dangling references");
}
EndTransferEvent endEvent = new EndTransferEvent();
if (languageFilter != null) {
endEvent = (EndTransferEvent) languageFilter.filter(endEvent);
}
if (exportBaseModelFilter != null) {
endEvent = (EndTransferEvent) exportBaseModelFilter.filter(endEvent);
}
if (rounder != null) {
endEvent = (EndTransferEvent) rounder.filter(endEvent);
}
if (validator != null) {
validator.validate(endEvent);
}
if (function != Config.FC_VALIDATE) {
iomFile.write(endEvent);
}
if (validator != null)
validator.close();
if (languageFilter != null) {
languageFilter.close();
}
if (exportBaseModelFilter != null) {
exportBaseModelFilter.close();
}
recman.close();
}
use of ch.interlis.ili2c.metamodel.Topic in project ili2db by claeis.
the class TransferFromXtf method doit.
public void doit(IoxReader reader, Config config, Map<String, BasketStat> stat, CustomMapping customMapping1) throws IoxException, Ili2dbException {
if (functionCode == Config.FC_UPDATE || functionCode == Config.FC_REPLACE) {
if (!createBasketCol) {
throw new Ili2dbException("update/replace requires a basket column");
}
}
if (functionCode != Config.FC_DELETE) {
if (readIliTid && !Config.TID_HANDLING_PROPERTY.equals(config.getTidHandling())) {
throw new Ili2dbException("TID import requires a " + DbNames.T_ILI_TID_COL + " column");
}
}
this.customMapping = customMapping1;
// limit import to given BIDs
HashSet<String> limitedToBids = null;
{
String baskets = config.getBaskets();
if (baskets != null) {
String[] basketidv = baskets.split(ch.interlis.ili2c.Main.MODELS_SEPARATOR);
limitedToBids = new HashSet<String>();
for (String basketid : basketidv) {
limitedToBids.add(basketid);
}
}
}
// limit import to given TOPICs
HashSet<String> limitedToTopics = null;
{
String topics = config.getTopics();
if (topics != null) {
String[] topicv = topics.split(ch.interlis.ili2c.Main.MODELS_SEPARATOR);
limitedToTopics = new HashSet<String>();
for (String topic : topicv) {
limitedToTopics.add(topic);
}
}
}
String datasetName = config.getDatasetName();
Long datasetSqlId = null;
today = new java.sql.Timestamp(System.currentTimeMillis());
if (doItfLineTables) {
tag2class = ch.interlis.iom_j.itf.ModelUtilities.getTagMap(td);
} else {
tag2class = ch.interlis.ili2c.generator.XSDGenerator.getTagMap(td);
}
isItfReader = reader instanceof ItfReader;
unknownTypev = new HashSet();
structQueue = new ArrayList<AbstractStructWrapper>();
boolean surfaceAsPolyline = true;
boolean ignoreUnresolvedReferences = config.isSkipReferenceErrors();
recman = new ObjectPoolManager();
try {
objPool = recman.newObjectPool(new IomObjectSerializer());
long importSqlId = 0;
long basketSqlId = 0;
long startTid = 0;
long endTid = 0;
long objCount = 0;
boolean referrs = false;
recConv = new FromXtfRecordConverter(td, ili2sqlName, tag2class, config, idGen, geomConv, conn, dbusr, isItfReader, oidPool, trafoConfig, class2wrapper, datasetName, schema);
if (functionCode == Config.FC_DELETE || functionCode == Config.FC_REPLACE) {
if (datasetName == null) {
throw new Ili2dbException("delete/replace requires a dataset name");
}
// delete existing data base on basketSqlId
datasetSqlId = Ili2db.getDatasetId(datasetName, conn, config);
if (datasetSqlId == null) {
if (functionCode == Config.FC_DELETE) {
// nothing to do
} else if (functionCode == Config.FC_REPLACE) {
// new dataset, not a replace!
datasetSqlId = oidPool.newObjSqlId();
try {
writeDataset(datasetSqlId, datasetName);
if (config.isCreateImportTabs()) {
importSqlId = writeImportStat(datasetSqlId, xtffilename, today, dbusr);
}
} catch (SQLException e) {
EhiLogger.logError(e);
} catch (ConverterException e) {
EhiLogger.logError(e);
}
}
} else {
deleteObjectsOfExistingDataset(datasetSqlId, config);
if (functionCode == Config.FC_DELETE) {
String sqlName = DbNames.DATASETS_TAB;
if (schema != null) {
sqlName = schema + "." + sqlName;
}
java.sql.PreparedStatement getstmt = null;
try {
String stmt = "DELETE FROM " + sqlName + " WHERE " + colT_ID + "= ?";
EhiLogger.traceBackendCmd(stmt);
getstmt = conn.prepareStatement(stmt);
getstmt.setLong(1, datasetSqlId);
getstmt.executeUpdate();
} catch (java.sql.SQLException ex) {
throw new Ili2dbException("failed to delete from " + sqlName, ex);
} finally {
if (getstmt != null) {
try {
getstmt.close();
getstmt = null;
} catch (java.sql.SQLException ex) {
EhiLogger.logError(ex);
}
}
}
}
if (config.isCreateImportTabs()) {
try {
importSqlId = writeImportStat(datasetSqlId, xtffilename, today, dbusr);
} catch (SQLException e) {
EhiLogger.logError(e);
} catch (ConverterException e) {
EhiLogger.logError(e);
}
}
}
} else if (functionCode == Config.FC_UPDATE) {
if (datasetName == null) {
throw new Ili2dbException("update requires a dataset name");
}
try {
datasetSqlId = Ili2db.getDatasetId(datasetName, conn, config);
if (datasetSqlId != null) {
} else {
datasetSqlId = oidPool.newObjSqlId();
writeDataset(datasetSqlId, datasetName);
}
if (config.isCreateImportTabs()) {
importSqlId = writeImportStat(datasetSqlId, xtffilename, today, dbusr);
}
} catch (SQLException e) {
EhiLogger.logError(e);
} catch (ConverterException e) {
EhiLogger.logError(e);
}
} else if (functionCode == Config.FC_IMPORT) {
try {
if (datasetName == null) {
datasetSqlId = oidPool.newObjSqlId();
if (xtffilename != null) {
datasetName = new java.io.File(xtffilename).getName() + "-" + Long.toString(datasetSqlId);
} else {
datasetName = Long.toString(datasetSqlId);
}
} else {
datasetSqlId = Ili2db.getDatasetId(datasetName, conn, config);
if (datasetSqlId != null) {
throw new Ili2dbException("dataset " + datasetName + " already exists");
} else {
datasetSqlId = oidPool.newObjSqlId();
}
}
if (Config.DELETE_DATA.equals(config.getDeleteMode())) {
EhiLogger.logState("delete existing data...");
Set<DbTableName> tables = new HashSet<DbTableName>();
for (Viewable viewable : class2wrapper.getViewables()) {
ViewableWrapper wrapper = class2wrapper.get(viewable);
DbTableName sqltableName = wrapper.getSqlTable();
if (!tables.contains(sqltableName)) {
tables.add(sqltableName);
if (customMapping.tableExists(conn, sqltableName)) {
// drop data
deleteExistingObjectsHelper(sqltableName, null);
}
}
}
// drop datasets+baskets
DbTableName sqltableName = new DbTableName(schema, DbNames.DATASETS_TAB);
if (customMapping.tableExists(conn, sqltableName)) {
deleteExistingObjectsHelper(sqltableName, null);
}
sqltableName = new DbTableName(schema, DbNames.BASKETS_TAB);
if (customMapping.tableExists(conn, sqltableName)) {
deleteExistingObjectsHelper(sqltableName, null);
}
}
writeDataset(datasetSqlId, datasetName);
if (config.isCreateImportTabs()) {
importSqlId = writeImportStat(datasetSqlId, xtffilename, today, dbusr);
}
} catch (SQLException e) {
EhiLogger.logError(e);
} catch (ConverterException e) {
EhiLogger.logError(e);
}
} else {
throw new IllegalArgumentException("unexpected function code " + functionCode);
}
if (functionCode == Config.FC_DELETE) {
return;
}
if (reader instanceof ItfReader) {
((ItfReader) reader).setBidPrefix(datasetName);
} else if (reader instanceof ItfReader2) {
((ItfReader2) reader).setBidPrefix(datasetName);
}
ch.interlis.iox_j.validator.Validator validator = null;
if (config.isValidation()) {
ValidationConfig modelConfig = new ValidationConfig();
modelConfig.mergeIliMetaAttrs(td);
String configFilename = config.getValidConfigFile();
if (configFilename != null) {
try {
modelConfig.mergeConfigFile(new File(configFilename));
} catch (java.io.IOException e) {
EhiLogger.logError("failed to read validator config file <" + configFilename + ">");
}
}
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.AREA_OVERLAP_VALIDATION, config.isDisableAreaValidation() ? ValidationConfig.OFF : null);
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.DEFAULT_GEOMETRY_TYPE_VALIDATION, config.isSkipGeometryErrors() ? ValidationConfig.OFF : null);
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.ALLOW_ONLY_MULTIPLICITY_REDUCTION, config.isOnlyMultiplicityReduction() ? ValidationConfig.ON : null);
if (rounder == null) {
modelConfig.setConfigValue(ValidationConfig.PARAMETER, ValidationConfig.DISABLE_ROUNDING, ValidationConfig.TRUE);
}
IoxLogging errHandler = new ch.interlis.iox_j.logging.Log2EhiLogger();
LogEventFactory errFactory = new LogEventFactory();
errFactory.setDataSource(xtffilename);
PipelinePool pipelinePool = new PipelinePool();
validator = new ch.interlis.iox_j.validator.Validator(td, modelConfig, errHandler, errFactory, pipelinePool, config);
if (reader instanceof ItfReader2) {
((ItfReader2) reader).setIoxDataPool(pipelinePool);
}
}
// setup list of objects that have external/forward references
delayedObjects = new ArrayList<FixIomObjectExtRefs>();
HashMap<String, ClassStat> objStat = null;
StartBasketEvent basket = null;
// more baskets?
IoxEvent event = reader.read();
try {
boolean skipBasket = false;
while (event != null) {
if (event instanceof StartBasketEvent) {
basket = (StartBasketEvent) event;
// do not import this this basket?
if ((limitedToBids != null && !limitedToBids.contains(basket.getBid())) || (limitedToTopics != null && !limitedToTopics.contains(basket.getType()))) {
// do not import this basket
skipBasket = true;
EhiLogger.logState("Skip Basket " + basket.getType() + "(oid " + basket.getBid() + ")");
} else {
// import this basket
EhiLogger.logState("Basket " + basket.getType() + "(oid " + basket.getBid() + ")...");
skipBasket = false;
try {
if (rounder != null) {
event = rounder.filter(event);
}
if (validator != null) {
validator.validate(event);
}
if (languageFilter != null) {
event = languageFilter.filter(event);
}
Long existingBasketSqlId = null;
if (functionCode == Config.FC_UPDATE) {
// read existing oid/sqlid mapping (but might also be a new basket)
existingObjectsOfCurrentBasket = new HashMap<String, HashSet<Long>>();
Topic topic = (Topic) td.getElement(basket.getType());
boolean hasBid = topic.getBasketOid() != null;
if (readIliBid || hasBid) {
existingBasketSqlId = readExistingSqlObjIds(reader instanceof ItfReader, basket.getBid());
if (existingBasketSqlId == null) {
// new basket
basketSqlId = oidPool.getBasketSqlId(basket.getBid());
} else {
// existing basket
basketSqlId = existingBasketSqlId;
// drop existing structeles
dropExistingStructEles(basket.getType(), basketSqlId);
}
} else {
String[] topicv = new String[] { basket.getType() };
Configuration dummy = new Configuration();
long[] basketSqlIds = Ili2db.getBasketSqlIdsFromTopic(topicv, dummy, conn, config);
for (long oldBasketSqlId : basketSqlIds) {
// read existing objects from baskets with same topic
readExistingSqlObjIds(reader instanceof ItfReader, topic, oldBasketSqlId);
// drop existing sturct eles
dropExistingStructEles(basket.getType(), oldBasketSqlId);
}
// remove old baskets from dataset
removeBasketsFromDataset(basketSqlIds);
// new basket
existingBasketSqlId = null;
basketSqlId = oidPool.getBasketSqlId(basket.getBid());
}
} else {
basketSqlId = oidPool.getBasketSqlId(basket.getBid());
}
if (attachmentKey == null) {
if (xtffilename != null) {
attachmentKey = new java.io.File(xtffilename).getName() + "-" + Long.toString(basketSqlId);
} else {
attachmentKey = Long.toString(basketSqlId);
}
config.setAttachmentKey(attachmentKey);
}
if (existingBasketSqlId == null) {
Topic topic = (Topic) td.getElement(basket.getType());
boolean hasBid = topic.getBasketOid() != null;
writeBasket(datasetSqlId, basket, basketSqlId, attachmentKey, hasBid ? hasBid : readIliBid, basket.getDomains());
} else {
// TODO update attachmentKey of existing basket
// TODO update domains of existing basket
}
} catch (SQLException ex) {
EhiLogger.logError("Basket " + basket.getType() + "(oid " + basket.getBid() + ")", ex);
} catch (ConverterException ex) {
EhiLogger.logError("Basket " + basket.getType() + "(oid " + basket.getBid() + ")", ex);
}
startTid = oidPool.getLastSqlId();
objStat = new HashMap<String, ClassStat>();
objCount = 0;
String filename = null;
if (xtffilename != null) {
filename = new java.io.File(xtffilename).getName();
}
// save it for later output to log
stat.put(Long.toString(basketSqlId), new BasketStat(filename, basket.getType(), basket.getBid(), objStat));
}
} else if (event instanceof EndBasketEvent) {
if (reader instanceof ItfReader2) {
ArrayList<IoxInvalidDataException> dataerrs = ((ItfReader2) reader).getDataErrs();
if (dataerrs.size() > 0) {
if (!skipBasket) {
if (!config.isSkipGeometryErrors()) {
for (IoxInvalidDataException dataerr : dataerrs) {
EhiLogger.logError(dataerr);
}
}
}
((ItfReader2) reader).clearDataErrs();
}
}
if (!skipBasket) {
if (rounder != null) {
event = rounder.filter(event);
}
if (validator != null) {
validator.validate(event);
}
if (languageFilter != null) {
event = languageFilter.filter(event);
}
// fix external/forward references
ArrayList<FixIomObjectExtRefs> fixedObjects = new ArrayList<FixIomObjectExtRefs>();
for (FixIomObjectExtRefs fixref : delayedObjects) {
boolean skipObj = false;
for (IomObject ref : fixref.getRefs()) {
String xtfid = ref.getobjectrefoid();
Viewable aclass = fixref.getTargetClass(ref);
String rootClassName = Ili2cUtility.getRootViewable(aclass).getScopedName(null);
if (oidPool.containsXtfid(rootClassName, xtfid)) {
// reference now resolvable
} else {
// reference not yet known, try to resolve again at end of transfer
skipObj = true;
}
}
if (!skipObj) {
HashMap<String, ClassStat> fixrefObjStat = stat.get(Long.toString(fixref.getBasketSqlId())).getObjStat();
doObject(datasetName, fixref.getBasketSqlId(), fixref.getGenericDomains(), objPool.get(fixref.getRootTid()), fixrefObjStat);
fixedObjects.add(fixref);
}
}
delayedObjects.removeAll(fixedObjects);
if (functionCode == Config.FC_UPDATE) {
// delete no longer existing objects
deleteExisitingObjects(existingObjectsOfCurrentBasket);
}
// TODO update import counters
endTid = oidPool.getLastSqlId();
try {
if (config.isCreateImportTabs()) {
long importId = writeImportBasketStat(importSqlId, basketSqlId, startTid, endTid, objCount);
writeObjStat(importId, basketSqlId, objStat);
}
} catch (SQLException ex) {
EhiLogger.logError("Basket " + basket.getType() + "(oid " + basket.getBid() + ")", ex);
} catch (ConverterException ex) {
EhiLogger.logError("Basket " + basket.getType() + "(oid " + basket.getBid() + ")", ex);
}
}
skipBasket = false;
} else if (event instanceof ObjectEvent) {
if (!skipBasket) {
if (rounder != null) {
event = rounder.filter(event);
}
if (validator != null) {
validator.validate(event);
}
if (languageFilter != null) {
event = languageFilter.filter(event);
}
objCount++;
IomObject iomObj = ((ObjectEvent) event).getIomObject();
if (allReferencesKnown(basketSqlId, basket.getDomains(), iomObj)) {
// translate object
doObject(datasetName, basketSqlId, basket.getDomains(), iomObj, objStat);
}
}
} else if (event instanceof EndTransferEvent) {
if (rounder != null) {
event = rounder.filter(event);
}
if (validator != null) {
validator.validate(event);
}
if (languageFilter != null) {
event = languageFilter.filter(event);
}
{
EhiLogger.traceState("write delayed objects (" + delayedObjects.size() + ")...");
for (FixIomObjectExtRefs fixref : delayedObjects) {
boolean skipObj = false;
for (IomObject ref : fixref.getRefs()) {
String xtfid = ref.getobjectrefoid();
Viewable aclass = fixref.getTargetClass(ref);
String rootClassName = Ili2cUtility.getRootViewable(aclass).getScopedName(null);
if (oidPool.containsXtfid(rootClassName, xtfid)) {
// skip it; now resolvable
} else {
// object in another basket
if (fixref.isExternalTarget(ref) && (readIliTid || Ili2cUtility.isViewableWithOid(aclass))) {
// read object
Long sqlid = readObjectSqlid(aclass, xtfid);
if (sqlid == null) {
if (!ignoreUnresolvedReferences) {
EhiLogger.logError("unknown referenced object " + aclass.getScopedName(null) + " TID " + xtfid + " referenced from " + fixref.getRootTag() + " TID " + fixref.getRootTid());
referrs = true;
skipObj = true;
}
}
} else {
if (!ignoreUnresolvedReferences) {
EhiLogger.logError("unknown referenced object " + aclass.getScopedName(null) + " TID " + xtfid + " referenced from " + fixref.getRootTag() + " TID " + fixref.getRootTid());
referrs = true;
skipObj = true;
}
}
}
}
if (!skipObj) {
objStat = stat.get(Long.toString(fixref.getBasketSqlId())).getObjStat();
doObject(datasetName, fixref.getBasketSqlId(), fixref.getGenericDomains(), objPool.get(fixref.getRootTid()), objStat);
}
}
}
flushBatchedRecords();
EhiLogger.traceState("...EndTransferEvent done");
break;
} else if (event instanceof StartTransferEvent) {
if (rounder != null) {
event = rounder.filter(event);
}
if (validator != null) {
validator.validate(event);
}
if (languageFilter != null) {
event = languageFilter.filter(event);
}
}
event = reader.read();
}
if (referrs) {
throw new IoxException("dangling references");
}
} finally {
if (rounder != null) {
rounder.close();
rounder = null;
}
if (validator != null) {
validator.close();
validator = null;
}
if (languageFilter != null) {
languageFilter.close();
}
closePreparedStatements();
}
} finally {
recman.close();
}
}
use of ch.interlis.ili2c.metamodel.Topic in project ili2db by claeis.
the class Ili2db method verifyIfBasketColRequired.
private static void verifyIfBasketColRequired(List<Model> models, boolean createBasketCol) throws Ili2dbException {
if (createBasketCol) {
return;
}
List<String> modelsThatRequireBasketCol = new ArrayList<String>();
for (Model model : models) {
Iterator it = model.iterator();
while (it.hasNext()) {
Element el = (Element) it.next();
if (el instanceof Topic) {
Topic topic = (Topic) el;
if (topic.getExtending() != null) {
if (!modelsThatRequireBasketCol.contains(model.getName())) {
modelsThatRequireBasketCol.add(model.getName());
}
}
if (topic.getBasketOid() != null) {
if (!modelsThatRequireBasketCol.contains(model.getName())) {
modelsThatRequireBasketCol.add(model.getName());
}
}
}
}
}
if (modelsThatRequireBasketCol.size() > 0) {
Collections.sort(modelsThatRequireBasketCol);
StringBuffer modelNames = new StringBuffer();
String sep = "";
for (String modelName : modelsThatRequireBasketCol) {
modelNames.append(sep);
modelNames.append(modelName);
sep = ", ";
}
if (modelsThatRequireBasketCol.size() == 1) {
throw new Ili2dbException("Model " + modelNames + " requires column " + DbNames.T_BASKET_COL);
} else {
throw new Ili2dbException("Models " + modelNames + " require column " + DbNames.T_BASKET_COL);
}
}
}
use of ch.interlis.ili2c.metamodel.Topic in project ili2db by claeis.
the class ModelElementSelector method visitModel.
private void visitModel(HashSet<Element> accu, HashSet<Model> accuScope, Model model) {
if (model.equals(td.INTERLIS)) {
visitDomain(accu, accuScope, td.INTERLIS.BOOLEAN);
visitDomain(accu, accuScope, td.INTERLIS.HALIGNMENT);
visitDomain(accu, accuScope, td.INTERLIS.VALIGNMENT);
return;
}
Iterator topici = model.iterator();
while (topici.hasNext()) {
Object tObj = topici.next();
if (tObj instanceof Topic) {
Topic topic = (Topic) tObj;
visitTopic(accu, accuScope, topic);
} else if (tObj instanceof Viewable) {
visitViewable(accu, accuScope, (Viewable) tObj);
} else if (tObj instanceof Domain) {
visitDomain(accu, accuScope, (Domain) tObj);
}
}
}
Aggregations