-
Notifications
You must be signed in to change notification settings - Fork 57
feat(print-properties): Adding dorContainer
in each component and pageTemplate
in FormContainer and new print specific components
#1567
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
base: dev
Are you sure you want to change the base?
Changes from all commits
c37e13f
4c18c0e
284b555
7fba98a
4cfe392
494dfc7
b4be0d2
381e81f
31ab83e
015156b
e77b5fb
5826678
bfc4c38
8cbbb9a
87b7b28
6db0ce3
808c53d
67c0d75
93f4cd6
75b6dbe
5d4c10c
210c123
86725bd
e5ffbbc
595d377
2ed4df3
c63b043
3ce8fee
d0ca0ca
deb0260
7f78c96
18feef2
d13d4c9
037a05b
d5ae5ee
b354704
9cc34c2
feae3bc
3c43453
8c549d8
01702da
b1235ed
f4bf8b0
20cbdff
c93137e
6919e5c
eb83034
4839e9b
62c7b9c
3b08f13
22d0aab
f338a39
2ff362b
4972db7
f26179f
fdc896f
1a81263
ccd72ac
782b22a
c386970
e8ed183
666b982
90400f1
0203615
e37ac3f
1ebc0f5
801f380
f16a014
a623078
b06e3f0
c922a75
505f859
8c29f9d
c93aaeb
14b67b5
101ac15
6ba8381
0348263
aa7922c
1638553
ebd9a1c
8b8a9ff
186e2f2
2b12338
97c431c
b162562
6f4f9d4
6ee3b2d
36e3d81
7099f59
a24bbc7
bbae446
75cea1a
c3691a8
fea8ef2
ba11b3d
92263bd
6672daa
afbdc38
49bc204
5c31250
ca348c6
8c9fac3
cbba8d3
dafb885
2f0fca0
eed2b8f
5be2f47
4654c40
6cacd1a
9b1a530
26c61be
1422069
26bce99
6dec168
dcbdd97
32250b4
8e04220
421ae55
985d572
9163daa
4f14b84
7271dbd
1d7ea0e
508fcf1
6cea919
60f76b8
55b4478
3cd9b69
51536d0
1493849
c70c991
08f248b
21ce8a5
348a998
17511d7
055e0bd
4033a02
c5a5ce7
67b85eb
79453cb
4f058f6
10cad8d
6d5cc64
27801fd
0eb79c7
19823bc
dc883c2
2254fbc
0176a8a
c36d8b1
caebb6d
deb7224
5923b00
c14c706
458ba7e
4e75bf9
e1c9c6b
76e1e1e
c9c1ece
f280783
fb96806
72093f8
a123e80
f546d7a
21232e6
6b88e53
9303798
e52b5b8
3fc7106
cbdadff
2c19f21
18f6a81
19672f0
1c34827
878b757
69ab31f
c9e5940
72b9953
2fe2441
24f5f17
b6368be
6240d64
da5a1d6
847a75e
5842a9e
1ea10ea
eb913cc
e279a0f
3e31389
74a705a
97b6da7
7dc97ad
928a55f
fa6fa9c
263866b
e0a0705
0a1b1f6
f2d90ff
ab65a21
1ad3233
ed4d3db
3dfaf9e
033c045
218838c
9f2dbe4
0552726
311a435
92ce22b
0ad21f8
9922ae7
df06b22
9c82470
2238d97
28ee86d
752a6a0
7f0e888
cb2f416
cf3e157
8546c00
337a7fd
253511f
bd51553
bccb6eb
dbeab3f
a535dff
b8bf024
088b9e4
78233bc
fd61e5c
5d38f1d
106e4a2
f31f53a
0ff204a
663902b
e983814
64dc876
ae01455
e5b0758
5d1d584
553842c
89b76ac
7baa39b
96a1021
39b53f7
6c248f2
0d24201
ccc0afd
993df8f
e6fcb2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,18 @@ | |
|
||
import java.io.IOException; | ||
import java.math.BigDecimal; | ||
import java.util.*; | ||
import java.util.AbstractMap; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.function.Predicate; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
|
@@ -49,6 +60,7 @@ | |
import com.adobe.cq.forms.core.components.models.form.FieldType; | ||
import com.adobe.cq.forms.core.components.models.form.FormComponent; | ||
import com.adobe.cq.forms.core.components.models.form.Label; | ||
import com.adobe.cq.forms.core.components.models.form.print.dorapi.DorContainer; | ||
import com.adobe.cq.wcm.core.components.models.Component; | ||
import com.adobe.cq.wcm.core.components.util.ComponentUtils; | ||
import com.day.cq.i18n.I18n; | ||
|
@@ -58,6 +70,7 @@ | |
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
@@ -258,6 +271,7 @@ protected boolean getEditMode() { | |
} | ||
|
||
public static final String CUSTOM_DOR_PROPERTY_WRAPPER = "fd:dor"; | ||
public static final String CUSTOM_DOR_CONTAINER_WRAPPER = "dorContainer"; | ||
// used for DOR and SPA editor to work | ||
public static final String CUSTOM_JCR_PATH_PROPERTY_WRAPPER = "fd:path"; | ||
|
||
|
@@ -544,6 +558,10 @@ public Map<String, Object> getDorProperties() { | |
if (dorBindRef != null) { | ||
customDorProperties.put("dorBindRef", dorBindRef); | ||
} | ||
Map<String, Object> dorContainer = getDorContainer(); | ||
if (dorContainer != null) { | ||
customDorProperties.put(CUSTOM_DOR_CONTAINER_WRAPPER, dorContainer); | ||
} | ||
return customDorProperties; | ||
} | ||
|
||
|
@@ -567,4 +585,26 @@ private List<String> getDisabledXFAScripts() { | |
} | ||
return new ArrayList<>(disabledScripts); | ||
} | ||
|
||
/** | ||
* Returns the dor container properties. | ||
* | ||
* @return Map of dor container properties if `fd:dorContainer` node is present otherwise returns null | ||
*/ | ||
@JsonIgnore | ||
@Override | ||
public Map<String, Object> getDorContainer() { | ||
if (resource != null) { | ||
Resource dorContainerResource = resource.getChild("fd:dorContainer"); | ||
if (dorContainerResource != null) { | ||
DorContainer dorContainer = dorContainerResource.adaptTo(DorContainer.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is confusing -> DorContainer for each component, nomenclature needs to be improved, I believe you mean DorComponent and not DorContainer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a single interface for all components? (this seems to be the case, seeing the implementation), how large is it? if its very small, and will not be required to change frequently, then we can have it here, this will lead to removing of dependency of core components on newly introduced print artifact There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The name
Yes...we have a single interface for all components because they have a large number of common properties and almost half of them are non-primitive(objects of other classes). Since there were so many classes involved, that's why, @rismehta suggested moving these interfaces to a different artifact. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, so basically it encapsulates all other classes. Then we might have to live with print dependency. Just make sure that only interfaces are defined in the dependant print artifact. The implementations of these apis are in a different artifact (bundle), this will ensure keeping the dependency light and will be less prone to breaking core components. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep it lean, we have even segregated the interfaces into two bundles. |
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
if (dorContainer != null) { | ||
return objectMapper.convertValue(dorContainer, new TypeReference<Map<String, Object>>() {}); | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2022 Adobe | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | ||
package com.adobe.cq.forms.core.components.models.form; | ||
|
||
import java.util.Collections; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.osgi.annotation.versioning.ProviderType; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@ProviderType | ||
public class FormComponentTest { | ||
@Test | ||
public void testGetDorContainer() { | ||
FormComponent formComponent = Mockito.mock(FormComponent.class); | ||
Mockito.when(formComponent.getDorContainer()).thenCallRealMethod(); | ||
assertEquals(Collections.emptyMap(), formComponent.getDorContainer()); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rismehta : Here I am assuming
dorContainer
node will be named asfd:dorContainer
in JCR, keeping it in consistency withfd:rules
and'fd:events
. I hope it is okay.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take this in spec review meeting