Skip to content

Commit 6192097

Browse files
committed
Fixing JPA XMLContentExporter for ARelationship
1 parent 3ecc662 commit 6192097

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

‎client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/Relationships.java‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.apache.syncope.client.ui.commons.wizards.any.UserWrapper;
5050
import org.apache.syncope.common.lib.to.AnyObjectTO;
5151
import org.apache.syncope.common.lib.to.AnyTO;
52-
import org.apache.syncope.common.lib.to.RelatableTO;
5352
import org.apache.syncope.common.lib.to.RelationshipTO;
5453
import org.apache.syncope.common.lib.to.RelationshipTypeTO;
5554
import org.apache.syncope.common.lib.types.AnyEntitlement;
@@ -121,12 +120,11 @@ protected Fragment getViewFragment() {
121120
Fragment viewFragment = new Fragment("relationships", "viewFragment", this);
122121
viewFragment.setOutputMarkupId(true);
123122

124-
List<RelationshipTO> relationships = getCurrentRelationships();
125-
viewFragment.add(relationships.isEmpty()
123+
viewFragment.add(anyTO.getRelationships().isEmpty()
126124
? new Label("relationships", new Model<>(getString("relationships.empty.list")))
127125
: new RelationshipViewPanel.Builder(pageRef).
128126
setAnyTO(anyTO).
129-
setRelationships(relationships).
127+
setRelationships(anyTO.getRelationships()).
130128
build("relationships"));
131129

132130
ActionsPanel<RelationshipTO> panel = new ActionsPanel<>("actions", null);
@@ -148,18 +146,6 @@ public void onClick(final AjaxRequestTarget target, final RelationshipTO ignore)
148146
return viewFragment;
149147
}
150148

151-
protected List<RelationshipTO> getCurrentRelationships() {
152-
return anyTO instanceof RelatableTO relatableTO
153-
? relatableTO.getRelationships()
154-
: List.of();
155-
}
156-
157-
protected void addNewRelationship(final RelationshipTO relaltionship) {
158-
if (anyTO instanceof RelatableTO relatableTO) {
159-
relatableTO.getRelationships().add(relaltionship);
160-
}
161-
}
162-
163149
@Override
164150
public boolean evaluate() {
165151
return !relationshipTypeRestClient.list().isEmpty();
@@ -270,7 +256,7 @@ public void onEvent(final IEvent<?> event) {
270256
rel.setOtherEndKey(right.getKey());
271257
rel.setOtherEndName(AnyObjectTO.class.cast(right).getName());
272258

273-
Relationships.this.addNewRelationship(rel);
259+
anyTO.getRelationships().add(rel);
274260

275261
Relationships.this.addOrReplace(getViewFragment().setRenderBodyOnly(true));
276262
target.add(Relationships.this);

‎core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected static String columnName(final Supplier<Stream<Attribute<?, ?>>> attrs
161161
}).filter(Objects::nonNull).findFirst().orElse(columnName);
162162

163163
if (Strings.CI.endsWith(name, "_ID")) {
164-
String left = StringUtils.substringBefore(name, "_");
164+
String left = StringUtils.substringBeforeLast(name, "_");
165165
String prefix = attrs.get().filter(attr -> left.equalsIgnoreCase(attr.getName())).findFirst().
166166
map(Attribute::getName).orElse(left);
167167
name = prefix + "_id";

0 commit comments

Comments
 (0)