Skip to content

Commit

Permalink
Merge branch 'release/26.x'
Browse files Browse the repository at this point in the history
* release/26.x:
  #3634 - Dropdowns look odd
  #3630 - Export of single document fails when username is too short
  #3609 - Feature editors do not show annotations in locked documents for multilabel String features
  #3630 - Export of single document fails when username is too short
  • Loading branch information
reckart committed Dec 13, 2022
2 parents 751a08f + 2a5cfdc commit 278b5b7
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public MultiSelectTextFeatureEditor(String aId, MarkupContainer aOwner,
add(new ConstraintsInUseIndicator(CID_TEXT_INDICATOR, getModel()));
}

/**
* Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied and
* feature doesn't match any constraint rule
*/
@SuppressWarnings("unchecked")
@Override
public void onConfigure()
Expand All @@ -94,6 +90,8 @@ public void onConfigure()
field = (FormComponent<ReorderableTag>) field.replaceWith(createInput());
}

// Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied
// and feature doesn't match any constraint rule
// if enabled and constraints rule execution returns anything other than green
var featState = getModelObject();
setVisible(!featState.feature.isHideUnconstraintFeature() || //
Expand Down
6 changes: 5 additions & 1 deletion inception/inception-api-formats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Optional;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
Expand Down Expand Up @@ -196,8 +197,10 @@ default File write(SourceDocument aDocument, CAS aCas, File aTargetFolder,
}

// If the writer produced only a single file, then that is the result
File exportFile = createTempFile(
FilenameUtils.getBaseName(aTargetFolder.listFiles()[0].getName()),
String filename = FilenameUtils.getBaseName(aTargetFolder.listFiles()[0].getName());
// temp-file prefix must be at least 3 chars
filename = StringUtils.rightPad(filename, 3, "_");
File exportFile = createTempFile(filename,
"." + FilenameUtils.getExtension(aTargetFolder.listFiles()[0].getName()));
// File exportFile = new File(aTargetFolder.getParent(),
// aTargetFolder.listFiles()[0].getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
Expand Down Expand Up @@ -171,7 +172,10 @@ public void onContextRefreshedEvent(ContextRefreshedEvent aEvent)
public File exportProject(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor)
throws ProjectExportException, IOException, InterruptedException
{
File projectZipFile = File.createTempFile(aRequest.getProject().getSlug(), ".zip");
String filename = aRequest.getProject().getSlug();
// temp-file prefix must be at least 3 chars
filename = StringUtils.rightPad(filename, 3, "_");
File projectZipFile = File.createTempFile(filename, ".zip");
boolean success = false;
try {
exportProject(aRequest, aMonitor, projectZipFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ public ResponseEntity<String> projectCreate( //

// If the current filename does not start with "." and is in the root folder of the ZIP,
// import it as a source document
File zipFile = File.createTempFile(aFile.getOriginalFilename(), ".zip");
String filename = aFile.getOriginalFilename();
// temp-file prefix must be at least 3 chars
filename = StringUtils.rightPad(filename, 3, "_");
File zipFile = File.createTempFile(filename, ".zip");
aFile.transferTo(zipFile);
ZipFile zip = new ZipFile(zipFile);

Expand All @@ -191,8 +194,7 @@ public ResponseEntity<String> projectCreate( //
ZipEntry entry = (ZipEntry) zipEnumerate.nextElement();

// If it is the zip name, ignore it
if ((FilenameUtils.removeExtension(aFile.getOriginalFilename()) + "/")
.equals(entry.toString())) {
if ((FilenameUtils.removeExtension(filename) + "/").equals(entry.toString())) {
continue;
}
// IF the current filename is META-INF/webanno/source-meta-data.properties store it as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public ResponseEntity<RResponse<RProject>> projectImport(
userRepository.isAdministrator(user));

Project importedProject;
File tempFile = File.createTempFile("webanno-training", null);
File tempFile = File.createTempFile("inception-project-import", null);
try (InputStream is = new BufferedInputStream(aFile.getInputStream());
OutputStream os = new FileOutputStream(tempFile);) {
if (!ZipUtils.isZipStream(is)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ public String getText()
// Some docs on how the templates work in Kendo, in case we need
// more fancy dropdowns
// http://docs.telerik.com/kendo-ui/framework/templates/overview
return "# if (data.reordered == 'true') { #"
+ "<div title=\"#: data.description #\"><b>#: data.name #</b></div>\n"
+ "# } else { #"
+ "<div title=\"#: data.description #\">#: data.name #</div>\n" + "# } #";
return "# if (data.reordered == 'true') { #" //
+ "<span title=\"#: data.description #\"><b>#: data.name #</b></span>\n" //
+ "# } else { #" //
+ "<span title=\"#: data.description #\">#: data.name #</span>\n" //
+ "# } #";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@

public class FileUploadDownloadHelper
{
private static final String INCEPTION_TMP_FILE_PREFIX = "inception_file";

private final Logger log = LoggerFactory.getLogger(getClass());

private final IFileCleaner fileTracker;

private final String INCEPTION_TMP_FILE_PREFIX = "inception_file";

public FileUploadDownloadHelper(Application application)
{
fileTracker = application.getResourceSettings().getFileCleaner();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<i class="fas fa-external-link-alt"></i>
</a>
</div>
<input style="width: 1%;" wicket:id="value" class="form-control" type="text"/>
<input style="width: 1%;" wicket:id="value" type="text"/>
</div>
<div wicket:id="descriptionContainer" class="scrolling border border-top-0 rounded-bottom p-1" style="max-height: 4.5rem; word-wrap: break-word;" readonly>
<small class="text-muted" wicket:id="description"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class ConceptFeatureEditor
public ConceptFeatureEditor(String aId, MarkupContainer aItem, IModel<FeatureState> aModel,
IModel<AnnotatorState> aStateModel, AnnotationActionHandler aHandler)
{
super(aId, aItem, aModel, aStateModel, aHandler);
super(aId, aItem, aModel);

AnnotationFeature feat = getModelObject().feature;
ConceptFeatureTraits traits = readFeatureTraits(feat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public abstract class ConceptFeatureEditor_ImplBase
private @SpringBean EntityLinkingProperties entityLinkingProperties;

public ConceptFeatureEditor_ImplBase(String aId, MarkupContainer aItem,
IModel<FeatureState> aModel, IModel<AnnotatorState> aStateModel,
AnnotationActionHandler aHandler)
IModel<FeatureState> aModel)
{
super(aId, aItem, new CompoundPropertyModel<>(aModel));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,25 @@ final class KBHandleTemplate
public String getText()
{
StringBuilder sb = new StringBuilder();
sb.append("<div>");
sb.append(" <div class=\"item-title\">");
sb.append("<span class=\"item-title\">");
// We cannot use && here because that causes an XML parse error in the browser - so we nest
// the if clauses...
sb.append(" # if (data.rank) { if (data.rank != '0') { #");
sb.append(" <span class=\"item-rank\">");
sb.append(" [${ data.rank }]");
sb.append(" </span>");
sb.append(" <span class=\"item-rank\">[${ data.rank }]</span>");
sb.append(" # } } #");
sb.append(" ${ data.uiLabel }");
sb.append(" </div>");
sb.append(" <div class=\"item-identifier\">");
sb.append(" ${ data.identifier }");
sb.append(" </div>");
sb.append(" <div class=\"item-description\">");
sb.append(" ${ data.description }");
sb.append(" </div>");
sb.append(" ${ data.uiLabel }");
sb.append("</span>");
sb.append("<div class=\"item-identifier\">");
sb.append(" ${ data.identifier }");
sb.append("</div>");
sb.append("<div class=\"item-description\">");
sb.append(" ${ data.description }");
sb.append("</div>");
if (DEVELOPMENT.equals(Application.get().getConfigurationType())) {
sb.append(" <div class=\"item-description\">");
sb.append(" ${ data.debugInfo }");
sb.append(" </div>");
sb.append("<div class=\"item-description\">");
sb.append(" ${ data.debugInfo }");
sb.append("</div>");
}
sb.append("</div>");
return sb.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,86 @@ public class MultiValueConceptFeatureEditor
{
private static final long serialVersionUID = -8326017157405023711L;

private static final String CID_VALUE = "value";

private @SpringBean FeatureSupportRegistry featureSupportRegistry;

private MultiSelect<KBHandle> focusComponent;
private final AnnotationActionHandler handler;
private final IModel<AnnotatorState> stateModel;

private FormComponent<Collection<KBHandle>> focusComponent;

public MultiValueConceptFeatureEditor(String aId, MarkupContainer aItem,
IModel<FeatureState> aModel, IModel<AnnotatorState> aStateModel,
AnnotationActionHandler aHandler)
{
super(aId, aItem, aModel, aStateModel, aHandler);
super(aId, aItem, aModel);

focusComponent = new KBHandleMultiSelect("value", aHandler, aStateModel);
handler = aHandler;
stateModel = aStateModel;

focusComponent = createInput();
add(focusComponent);
}

@SuppressWarnings("unchecked")
@Override
public void onConfigure()
{
super.onConfigure();

// Workaround for https://github.com/sebfz1/wicket-jquery-ui/issues/352
if ((isEnabledInHierarchy() && !(focusComponent instanceof MultiSelect))
|| !isEnabledInHierarchy() && (focusComponent instanceof MultiSelect)) {
focusComponent = (FormComponent<Collection<KBHandle>>) focusComponent
.replaceWith(createInput());
}
}

private FormComponent<Collection<KBHandle>> createInput()
{
if (isEnabledInHierarchy()) {
return createEditableInput();
}
else {
return createReadOnlyInput();
}
}

private FormComponent<Collection<KBHandle>> createEditableInput()
{
return new KBHandleMultiSelect(CID_VALUE, handler, stateModel);
}

@SuppressWarnings({ "unchecked", "rawtypes" })
private FormComponent<Collection<KBHandle>> createReadOnlyInput()
{
var input = new com.googlecode.wicket.kendo.ui.form.multiselect. //
MultiSelect<KBHandle>(CID_VALUE)
{
private static final long serialVersionUID = 1L;

@Override
public void onConfigure(JQueryBehavior aBehavior)
{
super.onConfigure(aBehavior);
styleMultiSelect(aBehavior);
}
};
input.setChoiceRenderer(
new org.apache.wicket.markup.html.form.ChoiceRenderer<>("uiLabel", "identifier"));
input.setChoices(() -> input.getModel().map(ArrayList::new).getObject());
return (FormComponent) input;
}

private void styleMultiSelect(JQueryBehavior aBehavior)
{
aBehavior.setOption("autoWidth", true);
aBehavior.setOption("animation", false);
aBehavior.setOption("delay", 250);
aBehavior.setOption("height", 300);
}

@Override
public FormComponent<Collection<KBHandle>> getFocusComponent()
{
Expand Down Expand Up @@ -113,10 +179,8 @@ public void onConfigure(JQueryBehavior aBehavior)
{
super.onConfigure(aBehavior);

aBehavior.setOption("autoWidth", true);
aBehavior.setOption("animation", false);
aBehavior.setOption("delay", 250);
aBehavior.setOption("height", 300);
styleMultiSelect(aBehavior);

// These three settings should avoid a query when simply clicking into the multiselect
// field, but they seem to have no effect
// aBehavior.setOption("autoBind", false);
Expand Down

0 comments on commit 278b5b7

Please sign in to comment.