Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/open notice with attributes #22

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7ff5ee4
Added the ability to open an existing notice for editing (not fully f…
rousso Jan 23, 2023
a585661
Merge branch 'develop' into open-notice
rousso Jan 23, 2023
9449bd1
Added jQuery + jQuery XPath plugin
rousso Jan 27, 2023
a96750b
Improved control of repeatable elements. Cleaned-up and commented code.
rousso Feb 24, 2023
73939b0
Fixed instance counting issue when reloading a form.
rousso Feb 25, 2023
027968f
Fixed language switching issue.
rousso Feb 25, 2023
4462bbc
Switched to XPath 2.0 by using jQuery
rousso Feb 25, 2023
76f000e
TEDEFO-2456 started work on this to investigate problems. Dynamically…
rouschr Aug 28, 2023
d1b1f13
TEDEFO-2456 improvements in attribute field generation (work in progr…
rouschr Aug 29, 2023
b08993b
TEDEFO-2456 work to use the attribute fields, some tests do not pass …
rouschr Aug 30, 2023
794125d
TEDEFO-2456 updated tests to align with data of SDK 1.9.0 and the XML…
rouschr Aug 31, 2023
aa4b0d3
TEDEFO-2456 various improvements and small fixes (work in progress).
rouschr Aug 31, 2023
41f3dee
TEDEFO-2456 various improvements in the back-end code. Removing some …
rouschr Sep 1, 2023
ab69d04
TEDEFO-2456 added autoDownload in application.yamnl. Added auto infer…
rouschr Sep 1, 2023
e02724d
TEDEFO-2630, TEDEFO-2631 various code improvements for readability, l…
rouschr Sep 7, 2023
fd02686
TEDEFO-2631 addition of skipIfNoValue, a boolean allowing to skip emp…
rouschr Sep 7, 2023
9ba8b02
TEDEFO-2630 added sortXml boolean, add fusion logic which fixes the c…
rouschr Sep 8, 2023
ca5acc4
TEDEFO-2456 removing unused import.
rouschr Sep 15, 2023
0004f2d
TEDEFO-2360 doing fixes testing against notice type 16, adding more d…
rouschr Oct 10, 2023
f0a3fe7
TEDEFO-2630 fixing nesting repeated nodes test, as it got broken thro…
rouschr Oct 11, 2023
52f8434
TEDEFO-2630 putting XML generation booleans into application.yaml
rouschr Oct 12, 2023
24fb6bb
TEDEFO-2630 improving the unit tests and use of constants, proper che…
rouschr Oct 12, 2023
636abc2
TEDEFO-2630 small change in the logs to make it more coherent.
rouschr Oct 12, 2023
51d3cfc
TEDEFO-2761 merge of some config files and README.
rouschr Oct 20, 2023
f7a8764
TEDEFO-2761 merge of notice-type-definition.js (taking code of open-n…
rouschr Oct 20, 2023
efe12b8
Merge pull request #21 from OP-TED/update/open-notice
rousso Oct 20, 2023
3b8cbe8
TEDEFO-2769 preliminary merge of config files and javascript
rouschr Oct 20, 2023
4d716f3
TEDEFO-2769 merge with work of field attributes branch (2456). Remain…
rouschr Oct 20, 2023
8e7dd38
TEDEFO-2769 putting debug to false, makes the XML a bit lighter (subj…
rouschr Oct 20, 2023
cfb4695
TEDEFO-2769 small fix on log (found by testing).
rouschr Oct 23, 2023
887355c
TEDEFO-2769 improving a unit test and setting skipIfEmpty to true.
rouschr Oct 23, 2023
731a908
TEDEFO-2769 adding Z at end of date or time to improve XML generation…
rouschr Oct 23, 2023
621f676
TEDEFO-2769 improvements in the conceptual model, in the debug json a…
rouschr Oct 24, 2023
ba560ab
Using SDK 1.11
rouschr Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,5 @@ You will encounter these terms in the code and code comments:
* **Visual Model**: Representation of the form used to fill in a notice, found in the `notice-types` folder of SDK
* **Conceptual Model**: An intermediate representation made of fields and nodes, based on the SDK `fields.json`
* **Physical Model**: The representation of a notice in XML, see "XML Generation"
* **UI**: User Interface, in the editor demo this means the forms, buttons, links in the browser
* **metadata**: In the editor demo this is generally SDK data
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ public class EformsNoticeEditorApp implements CommandLineRunner {
@Value("${eforms.sdk.versions}")
private List<String> supportedSdks;

@Value("${eforms.sdk.autodownload}")
private boolean autoDownload;

public static void main(final String[] args) {
logger.info("STARTING eForms Notice Editor Demo Application");
// See README.md on how to run server.
// https://spring.io/guides/gs/serving-web-content/

// Here you have access to command line args.
// Here you have access to command line arguments.
// logger.debug("args={}", Arrays.toString(args));

SpringApplication.run(EformsNoticeEditorApp.class, args);
Expand All @@ -48,6 +51,19 @@ public void run(String... args) throws Exception {
Validate.notEmpty(eformsSdkDir, "Undefined eForms SDK path");
Validate.notNull(supportedSdks, "Undefined supported SDK versions");

logger.info("SDK autoDownload: {}", autoDownload);
if (autoDownload) {
// This automatically downloads the supported officially SDKs.
// You can test any SDK (even release candidates) by doing a git clone and putting the SDK
// files manually inside the folder where it would normally be downloaded.
autoDownloadSupportedSdks();
} else {
logger.info(
"Not automatically downloading SDKs, put files manually or set autoDownload to true in application.yaml");
}
}

private void autoDownloadSupportedSdks() {
for (final String sdkVersion : supportedSdks) {
try {
SdkDownloader.downloadSdk(new SdkVersion(sdkVersion), Path.of(eformsSdkDir));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Optional;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -21,17 +22,32 @@ public class XmlRestController implements AsyncConfigurer {
@Autowired
private XmlWriteService xmlService;

/**
* Enriches the XML for human readability but it becomes invalid. Also adds .dot files and other
* debug files in target.
*/
@Value("${xml.generation.debug}")
private boolean debug;

@Value("${xml.generation.skipIfEmpty}")
private boolean skipIfNoValue;

@Value("${xml.generation.sortXmlElements}")
private boolean sortXmlElements;

/**
* Save: Takes notice as JSON and builds notice XML. The SDK version is in the notice metadata.
*/
@RequestMapping(value = "/notice/save/validation/none", method = RequestMethod.POST,
produces = SdkService.MIME_TYPE_XML, consumes = SdkService.MIME_TYPE_JSON)
public void saveNotice(final HttpServletResponse response, final @RequestBody String noticeJson)
public void saveNotice(final HttpServletResponse response,
final @RequestBody String noticeJson)
throws Exception {
// Enriches the XML for human readability but it becomes invalid.
// Also adds .dot files in target.
final boolean debug = false;
xmlService.saveNoticeAsXml(Optional.of(response), noticeJson, debug);
// For the XML generation config booleans, see application.yaml
xmlService.saveNoticeAsXml(Optional.of(response), noticeJson,
debug,
skipIfNoValue,
sortXmlElements);
}

/**
Expand All @@ -42,7 +58,6 @@ public void saveNotice(final HttpServletResponse response, final @RequestBody St
produces = SdkService.MIME_TYPE_XML, consumes = SdkService.MIME_TYPE_JSON)
public void saveNoticeAndXsdValidate(final HttpServletResponse response,
final @RequestBody String noticeJson) throws Exception {
final boolean debug = false;
xmlService.validateUsingXsd(Optional.of(response), noticeJson, debug);
}

Expand All @@ -55,7 +70,6 @@ public void saveNoticeAndXsdValidate(final HttpServletResponse response,
produces = SdkService.MIME_TYPE_XML, consumes = SdkService.MIME_TYPE_JSON)
public void saveNoticeAndCvsValidate(final HttpServletResponse response,
final @RequestBody String noticeJson) throws Exception {
final boolean debug = false;
xmlService.validateUsingCvs(Optional.of(response), noticeJson, debug);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package eu.europa.ted.eforms.noticeeditor.helper.notice;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;

/**
* Conceptual field. Leaf in the conceptual tree. This holds non-metadata field information and the
* field id. This is not an SDK field, this only points to an SDK field to reference metadata.
* Conceptual field. Leaf in the conceptual tree. This holds non-metadata field information like the
* value and the associated SDK field id. This is not an SDK field, this only points to an SDK field
* to reference the metadata. A field item cannot have child items!
*/
@JsonPropertyOrder({"idUnique", "counter", "fieldId", "value"})
public class ConceptTreeField extends ConceptTreeItem {
private final String value;

Expand All @@ -14,7 +18,9 @@ public ConceptTreeField(final String idUnique, final String idInSdkFieldsJson, f
}

/**
* For convenience and to make it clear that the ID in the SDK is the field ID in this case.
* For convenience and to make it clear that the ID in the SDK is the field ID in this case. It
* can be used to get general information about the field (data from fields.json). This does not
* include the counter.
*/
public String getFieldId() {
return idInSdkFieldsJson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import java.util.Objects;
import org.apache.commons.lang3.Validate;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* Abstract item holding common information. References SDK metadata.
* Abstract item holding common conceptual information for a notice. References SDK metadata.
*/
public abstract class ConceptTreeItem {
/**
* Unique identifier among children at same level.
* Unique identifier among children at same level. Counter excluded.
*/
private final String idUnique;

/**
* This id is not unique as some concept items can be repeatead while still have the same metadata
* (pointing to same field or same node multiple times).
* (pointing to same field or same node multiple times). A counter helps to differentiate them.
*/
protected final String idInSdkFieldsJson;

Expand All @@ -32,12 +33,17 @@ protected ConceptTreeItem(final String idUnique, final String idInSdkFieldsJson,
}

/**
* @return Unique identifier among children at same level.
* @return Unique identifier among children at same level. Counter excluded.
*/
public String getIdUnique() {
return idUnique;
}

@JsonIgnore // This will be covered by getFieldId and getNodeId
public String getIdInSdkFieldsJson() {
return idInSdkFieldsJson;
}

public int getCounter() {
return counter;
}
Expand All @@ -50,6 +56,7 @@ public String toString() {

@Override
public int hashCode() {
// Important: the counter is taken into account, this matters for repeatable items.
return Objects.hash(counter, idInSdkFieldsJson, idUnique);
}

Expand All @@ -65,6 +72,7 @@ public boolean equals(Object obj) {
return false;
}
ConceptTreeItem other = (ConceptTreeItem) obj;
// Important: the counter is taken into account, this matters for repeatable items.
return counter == other.counter && Objects.equals(idInSdkFieldsJson, other.idInSdkFieldsJson)
&& Objects.equals(idUnique, other.idUnique);
}
Expand Down
Loading