use of ch.interlis.ili2c.metamodel.AbstractClassDef in project ili2db by claeis.
the class TransferFromXtf method getStructs_Helper.
private void getStructs_Helper(AbstractClassDef aclass, HashSet<AbstractClassDef> accu) {
if (accu.contains(aclass)) {
return;
}
java.util.Set seed = null;
if (aclass instanceof Table && !((Table) aclass).isIdentifiable()) {
// STRUCTURE
seed = aclass.getExtensions();
} else {
// CLASS
seed = new HashSet();
seed.add(aclass);
}
for (Object defo : seed) {
AbstractClassDef def = (AbstractClassDef) defo;
if (accu.contains(def)) {
continue;
}
if (def instanceof Table && !((Table) def).isIdentifiable()) {
accu.add(def);
}
while (def != null) {
Iterator attri = def.iterator();
while (attri.hasNext()) {
Object attro = attri.next();
if (attro instanceof AttributeDef) {
AttributeDef attr = (AttributeDef) attro;
Type type = attr.getDomain();
if (type instanceof CompositionType) {
CompositionType compType = (CompositionType) type;
getStructs_Helper(compType.getComponentType(), accu);
Iterator resti = compType.iteratorRestrictedTo();
while (resti.hasNext()) {
AbstractClassDef rest = (AbstractClassDef) resti.next();
getStructs_Helper(rest, accu);
}
}
}
}
// base viewable
def = (AbstractClassDef) def.getExtending();
if (accu.contains(def)) {
def = null;
}
}
}
}
use of ch.interlis.ili2c.metamodel.AbstractClassDef in project ili2db by claeis.
the class TransferFromXtf method readObjectSqlid.
private Long readObjectSqlid(Viewable xclass, String xtfid) {
String stmt = createQueryStmt4sqlid(xclass);
EhiLogger.traceBackendCmd(stmt);
java.sql.PreparedStatement dbstmt = null;
long sqlid = 0;
String sqlType = null;
try {
dbstmt = conn.prepareStatement(stmt);
dbstmt.clearParameters();
if ((xclass instanceof AbstractClassDef) && ((AbstractClassDef) xclass).getOid() != null && AbstractRecordConverter.isUuidOid(td, ((AbstractClassDef) xclass).getOid())) {
dbstmt.setObject(1, geomConv.fromIomUuid(xtfid));
} else {
dbstmt.setString(1, xtfid);
}
java.sql.ResultSet rs = dbstmt.executeQuery();
if (rs.next()) {
sqlid = rs.getLong(1);
sqlType = rs.getString(3);
} else {
// unknown object
return null;
}
} catch (java.sql.SQLException ex) {
EhiLogger.logError("failed to query " + xclass.getScopedName(null), ex);
} catch (ConverterException ex) {
EhiLogger.logError("failed to query " + xclass.getScopedName(null), ex);
} finally {
if (dbstmt != null) {
try {
dbstmt.close();
} catch (java.sql.SQLException ex) {
EhiLogger.logError("failed to close query of " + xclass.getScopedName(null), ex);
}
}
}
// remember found sqlid
Viewable aclass = (Viewable) tag2class.get(ili2sqlName.mapSqlTableName(sqlType));
oidPool.putXtfid2sqlid(Ili2cUtility.getRootViewable(aclass).getScopedName(null), aclass.getScopedName(null), xtfid, sqlid);
return sqlid;
}
use of ch.interlis.ili2c.metamodel.AbstractClassDef in project ili2db by claeis.
the class Viewable2TableMapper method isReferenced.
private static boolean isReferenced(Viewable viewable) {
if (viewable instanceof AbstractClassDef) {
AbstractClassDef aclass = (AbstractClassDef) viewable;
Iterator<RoleDef> rolei = aclass.getDefinedTargetForRoles();
while (rolei.hasNext()) {
RoleDef role = rolei.next();
AssociationDef assoc = (AssociationDef) role.getContainer();
if (!assoc.isLightweight()) {
return true;
}
if (!role.isAssociationEmbedded()) {
// opposide role is embedded into opposide class, so opposide class references this viewable
return true;
}
}
}
return false;
}
use of ch.interlis.ili2c.metamodel.AbstractClassDef in project ili2db by claeis.
the class ViewableWrapper method getOid.
public Domain getOid() {
if (isSecondaryTable()) {
return null;
}
Viewable def = getViewable();
if (!(def instanceof AbstractClassDef)) {
return null;
}
if ((def instanceof Table) && !((Table) def).isIdentifiable()) {
return null;
}
AbstractClassDef aclass = (AbstractClassDef) def;
if (aclass.getOid() != null) {
return aclass.getOid();
}
for (Object exto : aclass.getExtensions()) {
AbstractClassDef ext = (AbstractClassDef) exto;
if (ext.getOid() != null) {
return ext.getOid();
}
}
return null;
}
Aggregations