Revision 47663

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/StructureExtractorImpl.java
397 397
                    } else if( count>1 ) {
398 398
                        // TODO es una relacion 1:n
399 399
                        field.setAggregate(true);
400
                        field.setFkCodeName("$ID_"+tableInfo.getName());
400
                        field.setFkCodeName("$ID_"+fktableInfo.getName());
401 401
                        field.setFkTableName(fktableInfo.getName());
402 402
                        field.setSize(45);
403 403
                        field.setType(DataTypes.LIST);
......
487 487
                    attrdesc.getTags().set("dynform.label.empty", true);
488 488
                    attrdesc.getTags().set("dynform.resizeWeight", 100);
489 489
                    attrdesc.setFeatureAttributeEmulator(
490
                        "SELECT * FROM \""+xmlinfo.getNameWithPrefix(attrinfo.getFkTableName()) + "\" WHERE ( (\""+pk.getName()+"\") = (\""+xmlinfo.getNameWithPrefix(attrinfo.getFkTableName()) + "\".\""+pk.getName()+"\") )"                    
490
                        "SELECT * FROM \""+xmlinfo.getNameWithPrefix(attrinfo.getFkTableName()) + "\" WHERE ( (:\""+pk.getName()+"\") = (\""+xmlinfo.getNameWithPrefix(attrinfo.getFkTableName()) + "\".\""+pk.getName()+"\") )"                    
491 491
                    );
492 492
                    attrdesc.setRelationType(DynField_v2.RELATION_TYPE_AGGREGATE);
493 493
                }
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/CopyXML2dbImpl.java
145 145
            return this.store;
146 146
        }
147 147
        
148
        public Feature current_row() {
148
        public EditableFeature current_row() {
149 149
            return this.current_row;
150 150
        }
151 151

  
......
162 162
                for (FeatureAttributeDescriptor attrdesc : ft) {
163 163
                    if( attrdesc.isPrimaryKey() ) {
164 164
                       this.set(attrdesc.getName(), this.pkcounter++);
165
                    } else if( attrdesc.isForeingKey() ) {
165
                    } else if( attrdesc.isForeingKey() && StringUtils.startsWith(attrdesc.getName(), "$ID_")) {
166 166
                        ForeingKey fk = attrdesc.getForeingKey();
167 167
                        TableInfo table = this.tables.get(fk.getTableName().toLowerCase());
168 168
                        if( table != null ) {
......
195 195
            if( this.store!=null && this.current_row!=null ) {
196 196
                try {
197 197
                    
198
                    FeatureType ft = this.current_row.getType();
199
                    for (FeatureAttributeDescriptor attrdesc : ft) {
200
                        if( attrdesc.isForeingKey() ) {
201
                            ForeingKey fk = attrdesc.getForeingKey();
202
                            TableInfo table = this.tables.get(fk.getTableName().toLowerCase());
203
                            if( table != null ) {
204
                                if( current_row.isNull(attrdesc.getName())){
205
                                    this.set(attrdesc.getName(), table.getPkValue());
206
                                }
207
                            }
208
                        }
209
                    }
198
//                    FeatureType ft = this.current_row.getType();
199
//                    for (FeatureAttributeDescriptor attrdesc : ft) {
200
//                        if( attrdesc.isForeingKey() && !StringUtils.startsWith(attrdesc.getName(), "$ID_")) {
201
//                            ForeingKey fk = attrdesc.getForeingKey();
202
//                            TableInfo table = this.tables.get(fk.getTableName().toLowerCase());
203
//                            if( table != null ) {
204
//                                if( current_row.isNull(attrdesc.getName())){
205
//                                    this.set(attrdesc.getName(), table.getPkValue());
206
//                                }
207
//                            }
208
//                        }
209
//                    }
210 210
                    
211 211
//                    System.out.println("###: insert("+this.tableName+")");
212 212
                    this.store.insert(current_row);
......
305 305
                        String path_s = StringUtils.join(path, "/");
306 306
                        TableInfo table1 = getTableByPath(tablesPrefix, tables, path_s);
307 307
                        if( table1 != null ) {
308
                            String parentPath_s = StringUtils.removeEnd(FilenameUtils.getPath(path_s),"/");
309
                            TableInfo parentTable1 = getTableByPath(tablesPrefix, tables, parentPath_s);
308 310
                            table1.createRow();
311
                            if(parentTable1 != null && parentTable1.featureType.get(localName) != null) {
312
                                parentTable1.current_row().set(localName,table1.getPkValue());
313
                            }
309 314
                            for (int i = 0; i < attributes.getLength(); i++) {
310 315
                                String name = attributes.getLocalName(i);
311 316
                                String value = attributes.getValue(i);

Also available in: Unified diff