dlr-eoc / prosEO

prosEO – A Processing System for Earth Observation Data
GNU General Public License v3.0
14 stars 1 forks source link

CLI: Selection rule update does not work #86

Closed tangobravo62 closed 3 years ago

tangobravo62 commented 4 years ago

Updating a selection rule through the CLI does not work, neither from prompt nor from file: (1) From prompt: No prompt for rule entry given:

prosEO (S2)> productclass rule update --format=PLAIN L2A_TL
[ 1] FOR L1C_TL SELECT LatestValCover(0 D, 0 D) MANDATORY
     (Mode: process_tile, configured processors: [Sen2Cor_02.08.00_TEST_2020-06-03_TL])

[ 2] FOR L2A_DS SELECT LatestValCover(0 D, 0 D) MANDATORY
     (Mode: process_tile, configured processors: [Sen2Cor_02.08.00_TEST_2020-06-03_TL])

Select rule (empty field cancels): 1
(I2876) Selection rule with database ID 130 updated (new version 1)

(2) From file:

prosEO (S2)> productclass rule update --file=testfiles/S2_L2A_TL_rule.txt --format=PLAIN L2A_TL mode=process_tile configuredProcessors=Sen2Cor_02.08.00_TEST_2020-06-03_TL
[ 1] FOR L1C_TL SELECT LatestValCover(0 D, 0 D) MANDATORY
     (Mode: process_tile, configured processors: [Sen2Cor_02.08.00_TEST_2020-06-03_TL])

[ 2] FOR L2A_DS SELECT LatestValCover(0 D, 0 D) MANDATORY
     (Mode: process_tile, configured processors: [Sen2Cor_02.08.00_TEST_2020-06-03_TL])

Select rule (empty field cancels): 1
(E2806) Command failed (cause: org.springframework.web.client.HttpClientErrorException$BadRequest: 400 199 proseo-productclass-mgr (E2118) Syntax error in selection rule de.dlr.proseo.prodclmgr.rest.model.SelectionRuleString@6ec5ae9b[id=130,version=1,selectionRule=    FOR L1C_TL SELECT ValIntersect(0, 0);    FOR L2A_DS SELECT LatestValCover(0, 0),mode=process_tile,configuredProcessors=[Sen2Cor_02.08.00_TEST_2020-06-03_TL]]: Exactly one simple selection rule expected)

Input file contains the lines:

    FOR L1C_TL SELECT ValIntersect(0, 0);
    FOR L2A_DS SELECT LatestValCover(0, 0)

It was expected that both rules get replaced, not only one. Perhaps clarification of the help text is needed.

Removing the second selection rule from the file results in an error:

(E2806) Command failed (cause: org.springframework.web.client.HttpClientErrorException: 500 )

Log excerpt for ProductClassManager:

2020-07-02 12:35:02.455 TRACE 1 --- [nio-8080-exec-3] d.d.p.p.rest.ProductClassManager         : >>> modifySelectionRuleString(130, 127, de.dlr.proseo.prodclmgr.rest.model.SelectionRuleString@72836427[id=130,version=1,selectionRule=    FOR L1C_TL SELECT ValIntersect(0, 0),mode=process_tile,configuredProcessors=[Sen2Cor_02.08.00_TEST_2020-06-03_TL]])
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... parsing simple rule 'FOR L1C_TL SELECT ValIntersect(0, 0)' at offset 0
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... source product type found: L1C_TL
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... parsing policy 'ValIntersect(0, 0)' at offset 18
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... parsing simple policy 'VALINTERSECT(0, 0)' at offset 18
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... policy name found: VALINTERSECT
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... parsing delta time '0' against pattern '(\d+)\s*(?:\s(D|H|M|S))?'
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... found delta time with duration '0' and unit 'DAYS'
2020-07-02 12:35:02.463 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... parsing delta time '0' against pattern '(\d+)\s*(?:\s(D|H|M|S))?'
2020-07-02 12:35:02.464 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... found delta time with duration '0' and unit 'DAYS'
2020-07-02 12:35:02.464 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... adding policy 'ValIntersect(0 D, 0 D)'
2020-07-02 12:35:02.464 DEBUG 1 --- [nio-8080-exec-3] de.dlr.proseo.model.util.SelectionRule   : ... policy is mandatory: true
2020-07-02 12:35:02.480 ERROR 1 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist: de.dlr.proseo.model.SimplePolicy; nested exception is org.hibernate.PersistentObjectException: detached entity passed to persist: de.dlr.proseo.model.SimplePolicy] with root cause
org.hibernate.PersistentObjectException: detached entity passed to persist: de.dlr.proseo.model.SimplePolicy
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:127) ~[hibernate-core-5.3.10.Final.jar!/:5.3.10.Final]
[...]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
    at com.sun.proxy.$Proxy126.findByIdentifier(Unknown Source) ~[na:na]
    at de.dlr.proseo.prodclmgr.rest.ProductClassManager.modifySelectionRuleString(ProductClassManager.java:934) ~[classes!/:0.5.1]
    at de.dlr.proseo.prodclmgr.rest.ProductClassManager$$FastClassBySpringCGLIB$$df408eed.invoke(<generated>) ~[classes!/:0.5.1]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
[...]
tangobravo62 commented 3 years ago

Probably fixed with CLI 0.5.2 (commit e4b80a8). Test evidence to be added.

tangobravo62 commented 3 years ago

Fully fixed now:

prosEO (PTM)> productclass rule update PTM_L3
[ 1] FOR PTM_L2B SELECT ValIntersect(2 H, 7 M) MINCOVER(90)
     (Mode: OPER, configured processors: [PTML3_0.1.0_OPER_2020-03-25])

[ 2] FOR PTM_L2A SELECT ValIntersect(0 D, 0 D) MINCOVER(90)
     (Mode: OPER, configured processors: [PTML3_0.1.0_OPER_2020-03-25])

Select rule (empty field cancels): 1
Selection rule in Rule Language (empty field cancels, ^D terminates): 
FOR PTM_L2B SELECT ValIntersect(0,0) mincover(50)
(I2876) Selection rule with database ID 55 updated (new version 4)

prosEO (PTM)> productclass rule show PTM_L3
ID: 55
FOR PTM_L2B SELECT ValIntersect(0 D, 0 D) MINCOVER(50)
(Mode: OPER, configured processors: [PTML3_0.1.0_OPER_2020-03-25])

ID: 57
FOR PTM_L2A SELECT ValIntersect(0 D, 0 D) MINCOVER(90)
(Mode: OPER, configured processors: [PTML3_0.1.0_OPER_2020-03-25])