Skip to content

Commit

Permalink
Update Plate/Image naming to match new design proposal
Browse files Browse the repository at this point in the history
This removes the automatic setting of user-specified names in the
importer, so that later calls to retrieve the user-specified name are
guaranteed to return only what the user actually specified (or null by
default).  Plate and Image names supplied by the reader are trusted when
the user has not specified a name.  The name(s) will be set to the
relative path of the imported file only if both the user- and
reader-specified names are null.

The issue of 255 character limits on name fields has not been addressed
here, but a comment has been added so that it's easier to go back to
later.
  • Loading branch information
melissalinkert committed Dec 9, 2016
1 parent 3746fbe commit 94575d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,7 @@ protected ImportContainer singleFile(File file, ImportConfig config)
ic.setDoThumbnails(config.doThumbnails.get());
ic.setNoStatsInfo(config.noStatsInfo.get());
String configImageName = config.userSpecifiedName.get();
if (configImageName == null)
{
ic.setUserSpecifiedName(file.getName());
}
else
{
ic.setUserSpecifiedName(configImageName);
}
ic.setUserSpecifiedName(configImageName);
ic.setUserSpecifiedDescription(config.userSpecifiedDescription.get());
ic.setCustomAnnotationList(config.annotations.get());
return ic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void doImport() throws Throwable
{
ic = new ImportContainer(file, fads.get(file),
null, null, null, null);
ic.setUserSpecifiedName(file.getAbsolutePath());
library.importImage(ic, 0, 0, 1);
/*
library.importImage(file, 0, 0, 1, file.getAbsolutePath(),
Expand Down
15 changes: 14 additions & 1 deletion components/blitz/src/ome/formats/model/PixelsProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import static ome.formats.model.UnitsFactory.makeLength;

import java.io.File;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -124,14 +125,18 @@ public void process(IObjectContainerStore store) throws ModelException {
}

// Ensure that the Image name is set

// name supplied by user
String userSpecifiedName = store.getUserSpecifiedName();
if (userSpecifiedName != null) {
userSpecifiedName = userSpecifiedName.trim();
if (userSpecifiedName.isEmpty()) {
userSpecifiedName = null;
}
}
// name that will actually be set on the Image
String saveName = "";
// name supplied by the reader
String imageName;
if (image.getName() != null && image.getName().getValue() != null) {
imageName = image.getName().getValue().trim();
Expand All @@ -150,9 +155,17 @@ public void process(IObjectContainerStore store) throws ModelException {
}
saveName += " [" + imageName + "]";
}
} else {
} else if (imageName != null) {
saveName = imageName;
}
else {
saveName = reader.getCurrentFile();
saveName = saveName.substring(saveName.lastIndexOf(File.separator) + 1);
if (reader.getSeriesCount() > 1) {
saveName += " [" + imageIndex + "]";
}
}
// TODO: remove this if/when name is switched to TEXT in the DB
if (saveName != null && saveName.length() > 255) {
saveName = '…' + saveName.substring(saveName.length() - 254);
}
Expand Down
18 changes: 5 additions & 13 deletions components/blitz/src/ome/formats/model/WellProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static omero.rtypes.rint;
import static omero.rtypes.rstring;

import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;

Expand Down Expand Up @@ -96,23 +97,14 @@ private Plate validatePlate(int plateIndex) {
String userSpecifiedPlateName = store.getUserSpecifiedName();
String userSpecifiedPlateDescription = store.getUserSpecifiedDescription();

// precedence order for plate naming:
//
// 1. user specified, if not default name of imported file
// 2. reader supplied, if not null
// 3. user specified (name of imported file)
// 4. "Plate"
if (userSpecifiedPlateName != null) {
String currentFile = store.getReader().getCurrentFile();
if (!currentFile.endsWith(userSpecifiedPlateName) ||
plate.getName() == null)
{
plate.setName(rstring(userSpecifiedPlateName));
}
plate.setName(rstring(userSpecifiedPlateName));
}
if (plate.getName() == null) {
log.warn("Missing plate name for: " + container.LSID);
plate.setName(rstring("Plate"));
String filename = store.getReader().getCurrentFile();
filename = filename.substring(filename.lastIndexOf(File.separator) + 1);
plate.setName(rstring(filename));
}

if (userSpecifiedPlateDescription != null) {
Expand Down

0 comments on commit 94575d5

Please sign in to comment.