Commit 09e82815 authored by igoshin's avatar igoshin
Browse files

#14050 Seems finished

parent f0f18312
/**
* Copyright 2014 Global Crop Diversity Trust
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......@@ -34,6 +34,9 @@ import org.springframework.beans.factory.annotation.Autowired;
public class DwcaBuilder extends AbstractModelObject {
@Autowired
private DataSourceLoader dataSourceLoader;
private List<IDataSource> fileRoots = new ArrayList<IDataSource>();
private String workspaceFilename = null;
......@@ -236,6 +239,17 @@ public class DwcaBuilder extends AbstractModelObject {
JSONArray columns = sheetJ.getJSONArray("columns");
List<Column> columnList = new ArrayList<Column>();
List<Object[]> rows=null;
try {
rows = dataSourceLoader.loadRows(sourceSheet, 200);
} catch (UnsupportedDataFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
sourceSheet.updateData(rows);
List<Column> loadedColumns = sourceSheet.getColumns();
for (int x = 0; x < columns.length(); x++) {
JSONObject column = columns.getJSONObject(x);
......@@ -258,7 +272,16 @@ public class DwcaBuilder extends AbstractModelObject {
if (column.has("multiple"))
sourceColumn.setMultiple(column.getBoolean("multiple"));
columnList.add(sourceColumn);
if (loadedColumns.contains(sourceColumn)){
columnList.add(sourceColumn);
}
}
for (Column loadedColumn:loadedColumns){
if (!columnList.contains(loadedColumn)){
columnList.add(loadedColumns.indexOf(loadedColumn),loadedColumn);
}
}
sourceSheet.setColumns(columnList);
sourceSheetList.add(sourceSheet);
......
......@@ -120,4 +120,18 @@ public class Column extends AbstractModelObject {
this.groupPattern = groupPattern;
firePropertyChange("groupPattern", null, this.groupPattern);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Column column = (Column) o;
if (preferredName != null ? !preferredName.equals(column.preferredName) : column.preferredName != null)
return false;
return true;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment