@@ -97,6 +97,13 @@ classful_props_tibble <- function(objects_nodeset) {
97
97
select(- row )
98
98
}
99
99
100
+ content_properties <- {
101
+ ns <- entities_xml %> % xml_find_all(' //object[@class="ContentProperty"]' )
102
+ tibble(property_id = ns %> % confluence_id ) %> %
103
+ mutate(ns %> % props_tibble ) %> %
104
+ mutate(ns %> % classful_props_tibble )
105
+ }
106
+
100
107
# # Again, stuff like
101
108
# #
102
109
# # object_pages <- entities %>%
@@ -109,7 +116,8 @@ classful_props_tibble <- function(objects_nodeset) {
109
116
110
117
page_versions <- {
111
118
ns <- entities_xml %> % xml_find_all(' //object[@class="Page"]' )
112
- tibble(content_id = ns %> % confluence_id ) %> %
119
+ page_versions <-
120
+ tibble(content_id = ns %> % confluence_id ) %> %
113
121
mutate(ns %> % props_tibble ) %> %
114
122
mutate(ns %> % classful_props_tibble ) %> %
115
123
mutate(ns %> %
@@ -120,35 +128,29 @@ page_versions <- {
120
128
flatten = FALSE ) %> %
121
129
tibble(ids = . ) %> % rowwise %> %
122
130
transmute(content_property_ids = xml_text(ids ) %> % list ))
131
+ # # page_versions$content_property_ids (as a “multivalued foreign key”)
132
+ # # ought to contain the same information as
133
+ # # content_properties[c("content.Page", "property_id")]:
134
+ stopifnot({
135
+ relation1 <-
136
+ page_versions %> %
137
+ transmute(content_id , property_id = content_property_ids ) %> %
138
+ unnest_longer(property_id )
139
+ relation2 <-
140
+ content_properties %> %
141
+ filter(! is.na(content.Page )) %> %
142
+ transmute(content_id = content.Page , property_id )
143
+ by <- join_by(content_id , property_id )
144
+ anti_join(relation1 , relation2 , by = by ) %> % nrow == 0 &&
145
+ anti_join(relation2 , relation1 , by = by ) %> % nrow == 0
146
+ })
147
+ page_versions
123
148
}
124
149
125
- content_properties <- {
126
- ns <- entities_xml %> % xml_find_all(' //object[@class="ContentProperty"]' )
127
- tibble(property_id = ns %> % confluence_id ) %> %
128
- mutate(ns %> % props_tibble ) %> %
129
- mutate(ns %> % classful_props_tibble )
130
- }
131
-
132
- # # page_versions$content_property_ids (as a “multivalued foreign key”)
133
- # # ought to contain the same information as
134
- # # content_properties[c("content.Page", "property_id")]:
135
- stopifnot({
136
- relation1 <-
137
- page_versions %> %
138
- transmute(content_id , property_id = content_property_ids ) %> %
139
- unnest_longer(property_id )
140
- relation2 <-
141
- content_properties %> %
142
- filter(! is.na(content.Page )) %> %
143
- transmute(content_id = content.Page , property_id )
144
- by <- join_by(content_id , property_id )
145
- anti_join(relation1 , relation2 , by = by ) %> % nrow == 0 &&
146
- anti_join(relation2 , relation1 , by = by ) %> % nrow == 0
147
- })
148
-
149
150
bodies <- {
150
151
ns <- entities_xml %> % xml_find_all(' //object[@class="BodyContent"]' )
151
- tibble(body_id = ns %> % confluence_id ) %> %
152
+ bodies <-
153
+ tibble(body_id = ns %> % confluence_id ) %> %
152
154
mutate(ns %> % props_tibble ) %> %
153
155
mutate(.keep = " unused" ,
154
156
type = case_when(
@@ -157,20 +159,20 @@ bodies <- {
157
159
bodyType == 2 ~ " PageEtc" ) %> %
158
160
as_factor ) %> %
159
161
mutate(ns %> % classful_props_tibble )
162
+ stopifnot(bodies %> %
163
+ filter(is.na(type )) %> %
164
+ nrow == 0 )
165
+ stopifnot(bodies %> %
166
+ filter(! is.na(content.SpaceDescription )) %> %
167
+ filter(type != " SpaceDescription" ) %> %
168
+ nrow == 0 )
169
+ stopifnot(bodies %> %
170
+ filter(! is.na(content.CustomContentEntityObject )) %> %
171
+ filter(type != " CustomContentEntityObject" ) %> %
172
+ nrow == 0 )
173
+ bodies
160
174
}
161
175
162
- stopifnot(bodies %> %
163
- filter(is.na(type )) %> %
164
- nrow == 0 )
165
- stopifnot(bodies %> %
166
- filter(! is.na(content.SpaceDescription )) %> %
167
- filter(type != " SpaceDescription" ) %> %
168
- nrow == 0 )
169
- stopifnot(bodies %> %
170
- filter(! is.na(content.CustomContentEntityObject )) %> %
171
- filter(type != " CustomContentEntityObject" ) %> %
172
- nrow == 0 )
173
-
174
176
user2content <- {
175
177
ns <- entities_xml %> %
176
178
xml_find_all(' //object[@class="User2ContentRelationEntity"]' )
0 commit comments