Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentJB committed Jun 4, 2018
2 parents 0f5ec3e + f3910c4 commit 9f4b976
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/main/java/fr/jmmc/oitools/meta/CustomUnits.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public CustomUnits(final boolean required) {
super("UNIT_CUSTOM", "");
this.required = required;
}

/**
* Define the value of unit
* @param unit other CustomUnits instance
*/
public void set(final CustomUnits unit) {
set(unit.getStandardRepresentation());
}

/**
* Define the value of unit
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/fr/jmmc/oitools/model/OITable.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@

import fr.jmmc.oitools.OIFitsConstants;
import fr.jmmc.oitools.fits.FitsConstants;
import fr.jmmc.oitools.fits.FitsHeaderCard;
import fr.jmmc.oitools.fits.FitsTable;
import fr.jmmc.oitools.fits.FitsUtils;
import fr.jmmc.oitools.meta.ColumnMeta;
import fr.jmmc.oitools.meta.KeywordMeta;
import fr.jmmc.oitools.meta.Types;
import fr.nom.tam.fits.HeaderCard;
import java.util.logging.Level;

/**
Expand Down Expand Up @@ -130,8 +127,9 @@ protected final void copyTable(final OITable src) throws IllegalArgumentExceptio
}
}

// Copy header cards:
if (src.hasHeaderCards()) {
// Copy header cards ?
// disabled for now (how to ensure consistency if the table is modified ?)
if (false && src.hasHeaderCards()) {
// Copy references to Fits header cards:
getHeaderCards().addAll(src.getHeaderCards());
}
Expand All @@ -145,9 +143,17 @@ protected final void copyTable(final OITable src) throws IllegalArgumentExceptio
columnName = column.getName();
columnValue = src.getColumnValue(columnName);

if (columnValue == null) {
if (columnValue == null && !column.isOptional()) {
columnValue = createColumnArray(column, getNbRows());
}

// Copy custom units:
if (column.isCustomUnits()) {
final ColumnMeta srcColumn = src.getColumnDesc(columnName);
if (srcColumn != null && srcColumn.isCustomUnits()) {
column.getCustomUnits().set(srcColumn.getCustomUnits());
}
}

if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "COLUMN {0} = ''{1}''", new Object[]{columnName, columnValue});
Expand Down

0 comments on commit 9f4b976

Please sign in to comment.