Skip to content

Commit d6318ab

Browse files
KochTobiShraddha0903sven1103
authored
Implement missing eperimental variable functionality (#1274)
* Preserve order of levels * make it compile again * wip * wip * section off regions and add borders * Replace ontology-term CSS class * Remove CSS classes Replace `.vertical-list` by `.flex-vertical .width-full` Replace `.trailing-margin-large` by `.margin-bottom-07` Replace `.trailing-margin-normal` by `.margin-bottom-05` Replace `.trailing-margin-small` by `.margin-bottom-03` * wip * add missing variables * replace lumo with custom variables * move ButtonFactory * add icon button factory method * update demo * Fix label css * replace with classes * introduce delete event * wip * add restoration option for deleted variables * Add Nullable annotation to DialogBody.java#with method * remove test button * Fix value handling of level field * Add paste behaviour * address code smells * hide public constructor * simplify memento interface removes Speculative Generality * Handle validation * Make InputValidation combinable * require all snapshots to be serializable * adapt validation to validate multivariable constraints adds validation for duplicate variable names. * wip * Add DragDropList.java * Push UI code * extract classes and add add dialog * Load values and call the service missing check for deleted variables and changes to levels. Adding, deleting, renaming and changing the unit of a variable are functional now. * remove unused method * Add empty input if no variables exist * Add variable deletion confirm dialog * add bold css class * add tooltip to locked levels Co-authored-by: Shraddha Pawar <[email protected]> * extract change records * add scroll css classes * make drag-drop configurable * replace lumo var with own variable definition Replaces the lumo variable with a custom variable. The custom variable has the same value as the lumo variable without depending on lumo and makes editing css in editors easier (as the variable is defined in the project scope and not only after compilation) * remove duplicate css classes * use correct css class * Fix import * propagate level changes address code smells * Cleanup methods * Fix inverted boolean * respect enabled state when adding and removing items * use correct variable name in changes * Prevent unintended modification on card collection Remove domain ExperimentalGroup from UI component * reload experimental variables upon completion * address code smells * enhance dragdrop hides the dragged element during dragging * reload information on attach event * remove unused code * return experimental variables sorted by variable name * Correct icon colors * update indexes * change dialog size back to medium * remove unused css * fix border colors borders in dialogs have a specific color. borders can be specifically set to not have any color. Co-authored-by: Shraddha Pawar <[email protected]> * Trim variable name input * Fix padding for linked orcid account * Change message for duplicate variable names Co-authored-by: Shraddha Pawar <[email protected]> * address wrong padding Co-authored-by: Shraddha Pawar <[email protected]> * Remove specific border color for choice box Co-authored-by: Shraddha Pawar <[email protected]> * Clarify error colors * Add dialog with dangerous confirm action * Ask directly instead of restore option Instead of presenting the user with the list of deleted experimental variables in the end, directly ask them when they delete the variable. Removes the need for the restore option as they only get removed when users confirm the intended action. * Improve check for defined variables Ignores leading and tailing whitespace when comparing variable name to existing variable names. * Do not silently remove dupliate levels in experimental variable Co-authored-by: Sven F. <[email protected]> * address review Co-authored-by: Sven F. <[email protected]> * address review * Fix sorting of variables * Remove duplicate error when level value changes Co-authored-by: Shraddha Pawar <[email protected]> * Remove error message for duplicate variable name When editing a duplicated variable name, the error message is removed. * replace choice-box css * Change error text Co-authored-by: Shraddha Pawar <[email protected]> * update dev.bundle * Fix css color * Change delete confirm text Co-authored-by: Shraddha Pawar <[email protected]> * Link javadoc Co-authored-by: Sven F. <[email protected]> * Add clarifying javadoc Co-authored-by: Sven F. <[email protected]> * remove all the generics from javadoc Co-authored-by: Sven F. <[email protected]> * address review * add missed change * address exception Co-authored-by: Sven F. <[email protected]> * Use deep copy instead of inplace modification Co-authored-by: Sven F. <[email protected]> * Remove comment I removed the comment and we will encounter the issue again if and when we try to implement a drag handle. Tracking it with our own github issue is not necessary as maybe another solution is found at a future time. * Provide exception supplier * Use UIHandle --------- Co-authored-by: KochTobi <[email protected]> Co-authored-by: Shraddha Pawar <[email protected]> Co-authored-by: Sven F. <[email protected]> Co-authored-by: Sven F. <[email protected]> Co-authored-by: Sven Fillinger <[email protected]>
1 parent cbf1d56 commit d6318ab

File tree

73 files changed

+4637
-1651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4637
-1651
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package life.qbic.application.commons;
2+
3+
/**
4+
* Interface to implement the Memento/Snapshot pattern. <a
5+
* href="https://refactoring.guru/design-patterns/memento">Memento Pattern</a> Originators of
6+
* Mementos or Creators of Snapshots should implement this interface.
7+
*/
8+
public interface CanSnapshot {
9+
10+
/**
11+
* Capture the internal state and expose it as a Snapshot.
12+
*
13+
* @return the created snapshot
14+
*/
15+
Snapshot snapshot();
16+
17+
/**
18+
* Adapts the internal state to match the information provided by the snapshot. The method can
19+
* fail throwing a {@link SnapshotRestorationException} for unknown types of Snapshots.
20+
* <p>
21+
* It is the responsibility of the implementation to make sure after successful application or
22+
* failure, the internal state of the object is valid.
23+
* <p>
24+
* After snapshot restoration failure. The object is expected to revert all modifications made by
25+
* the attempt.
26+
*
27+
* @param snapshot the snapshot to be restored
28+
* @throws SnapshotRestorationException thrown when snapshot restoration failed.
29+
*/
30+
void restore(Snapshot snapshot) throws SnapshotRestorationException;
31+
32+
/**
33+
* Indicates that a snapshot cannot be used to restore the state of the originator.
34+
*/
35+
class SnapshotRestorationException extends RuntimeException {
36+
37+
public SnapshotRestorationException(String message) {
38+
super(message);
39+
}
40+
41+
public SnapshotRestorationException(String message, Throwable cause) {
42+
super(message, cause);
43+
}
44+
}
45+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package life.qbic.application.commons;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* Interface for the Memento in the <a
7+
* href="https://refactoring.guru/design-patterns/memento">Memento Pattern</a>
8+
*/
9+
public interface Snapshot extends Serializable {
10+
11+
}

project-management/src/main/java/life/qbic/projectmanagement/application/VariableValueFormatter.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package life.qbic.projectmanagement.application;
22

3+
import static java.util.Objects.nonNull;
4+
35
import life.qbic.projectmanagement.domain.model.experiment.ExperimentalValue;
46

57
public class VariableValueFormatter {
@@ -15,7 +17,17 @@ private VariableValueFormatter() {}
1517
* present
1618
*/
1719
public static String format(ExperimentalValue experimentalValue) {
18-
String optionalUnit = experimentalValue.unit().map(unit -> " " + unit).orElse("");
19-
return experimentalValue.value() + optionalUnit;
20+
return format(experimentalValue.value(), experimentalValue.unit().orElse(null));
21+
}
22+
23+
/**
24+
* Formats the value and unit strings according to a standard format for experimental values.
25+
*
26+
* @param value the value
27+
* @param unit the unit
28+
* @return a String representation
29+
*/
30+
public static String format(String value, String unit) {
31+
return value + (nonNull(unit) ? " " + unit : "");
2032
}
2133
}

0 commit comments

Comments
 (0)