Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 19, 2023
2 parents bd91406 + de33942 commit 16994d1
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 33 deletions.
5 changes: 5 additions & 0 deletions gui/admin-gui/pom.xml
Expand Up @@ -225,6 +225,11 @@
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-astbuilder</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand Down
Expand Up @@ -40,10 +40,6 @@ public class ScriptExpressionPanel extends EvaluatorExpressionPanel {

public ScriptExpressionPanel(String id, IModel<ExpressionType> model) {
super(id, model);
ScriptExpressionWrapper wrapper = getEvaluatorValue();
if (wrapper == null || wrapper.isEmpty()) {
updateEvaluatorValue((ExpressionUtil.Language) null);
}
}

@Override
Expand Down Expand Up @@ -123,8 +119,6 @@ protected AceEditor createEditor(String id, IModel<String> model, int minSize) {
editorPanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
String updatedValue = ((AceEditor) editorPanel.getBaseFormComponent()).getConvertedInput();
updateEvaluatorValue(updatedValue);
target.add(getFeedback());
}
});
Expand All @@ -149,9 +143,11 @@ private void updateEvaluatorValue(ExpressionUtil.Language language) {
}

private void updateEvaluatorValue(String code) {
ExpressionType expressionType = getModelObject();
try {
ScriptExpressionEvaluatorType evaluator = getEvaluatorValue().code(code).toEvaluator();
ExpressionUtil.updateScriptExpressionValue(getModelObject(), evaluator);
expressionType = ExpressionUtil.updateScriptExpressionValue(expressionType, evaluator);
getModel().setObject(expressionType);
} catch (SchemaException ex) {
LOGGER.error("Couldn't update generate expression values: {}", ex.getLocalizedMessage());
getPageBase().error("Couldn't update generate expression values: " + ex.getLocalizedMessage());
Expand Down
Expand Up @@ -101,12 +101,11 @@ public SearchableItemsDefinitions additionalSearchContext(SearchContext ctx) {
ItemPath.create(UserType.F_PERSONAL_NUMBER)
));
SEARCHABLE_OBJECTS.put(RoleType.class, Arrays.asList(
ItemPath.create(RoleType.F_NAME),
ItemPath.create(RoleType.F_DISPLAY_NAME)
ItemPath.create(RoleType.F_NAME)

));
SEARCHABLE_OBJECTS.put(ServiceType.class, Arrays.asList(
ItemPath.create(ServiceType.F_NAME),
ItemPath.create(RoleType.F_DISPLAY_NAME),
ItemPath.create(ServiceType.F_URL)
));
SEARCHABLE_OBJECTS.put(ConnectorHostType.class, Arrays.asList(
Expand All @@ -119,10 +118,10 @@ public SearchableItemsDefinitions additionalSearchContext(SearchContext ctx) {
));
SEARCHABLE_OBJECTS.put(AbstractRoleType.class, Arrays.asList(
ItemPath.create(AbstractRoleType.F_IDENTIFIER),
ItemPath.create(AbstractRoleType.F_REQUESTABLE)
ItemPath.create(AbstractRoleType.F_REQUESTABLE),
ItemPath.create(RoleType.F_DISPLAY_NAME)
));
SEARCHABLE_OBJECTS.put(OrgType.class, Arrays.asList(
ItemPath.create(OrgType.F_DISPLAY_NAME),
ItemPath.create(OrgType.F_COST_CENTER),
ItemPath.create(OrgType.F_TENANT),
ItemPath.create(OrgType.F_PARENT_ORG_REF),
Expand Down
Expand Up @@ -73,20 +73,6 @@ protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelati
protected List<Component> createToolbarButtonsList(String idButton) {
List<Component> buttons = new ArrayList<>();

AjaxIconButton newObjectButton = new AjaxIconButton(
idButton,
Model.of("fa fa-circle-plus"),
createStringResource(getKeyOfTitleForNewObjectButton())) {
@Override
public void onClick(AjaxRequestTarget target) {
editItemPerformed(target, Model.of(createNewValue(target)), null);
}
};
newObjectButton.showTitleAsLabel(true);
newObjectButton.add(AttributeAppender.append("class", "btn btn-primary btn-sm"));
newObjectButton.add(new VisibleBehaviour(this::isCreateNewObjectVisible));
buttons.add(newObjectButton);

AjaxIconButton newObjectSimpleButton = new AjaxIconButton(
idButton,
new Model<>("fa fa-circle-plus"),
Expand All @@ -99,11 +85,25 @@ public void onClick(AjaxRequestTarget target) {
newItemPerformed(target, null);
}
};
newObjectSimpleButton.add(AttributeAppender.append("class", "btn btn-default btn-sm ml-3"));
newObjectSimpleButton.add(AttributeAppender.append("class", "btn btn-primary btn-sm ml-3"));
newObjectSimpleButton.add(new VisibleBehaviour(this::isCreateNewObjectSimpleVisible));
newObjectSimpleButton.showTitleAsLabel(true);
buttons.add(newObjectSimpleButton);

AjaxIconButton newObjectButton = new AjaxIconButton(
idButton,
Model.of("fa fa-circle-plus"),
createStringResource(getKeyOfTitleForNewObjectButton())) {
@Override
public void onClick(AjaxRequestTarget target) {
editItemPerformed(target, Model.of(createNewValue(target)), null);
}
};
newObjectButton.showTitleAsLabel(true);
newObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
newObjectButton.add(new VisibleBehaviour(this::isCreateNewObjectVisible));
buttons.add(newObjectButton);

return buttons;
}

Expand Down
Expand Up @@ -119,4 +119,9 @@ protected UserProfileStorage.TableId getTableId() {
protected String getKeyOfTitleForNewObjectButton() {
return "AssociationsTable.newObject";
}

@Override
protected boolean isCreateNewObjectVisible() {
return false;
}
}
Expand Up @@ -114,4 +114,9 @@ protected UserProfileStorage.TableId getTableId() {
protected String getKeyOfTitleForNewObjectButton() {
return "SynchronizationReactionTable.newObject";
}

@Override
protected boolean isCreateNewObjectVisible() {
return false;
}
}
Expand Up @@ -575,13 +575,13 @@ public static void updateLiteralExpressionValue(ExpressionType expression, List<
}
}

public static void updateScriptExpressionValue(
public static ExpressionType updateScriptExpressionValue(
ExpressionType expression, ScriptExpressionEvaluatorType evaluator) throws SchemaException {
updateExpressionEvaluator(
return updateExpressionEvaluator(
expression, evaluator, ScriptExpressionEvaluatorType.class, SchemaConstantsGenerated.C_SCRIPT);
}

private static <E extends Object> void updateExpressionEvaluator(
private static <E extends Object> ExpressionType updateExpressionEvaluator(
ExpressionType expression, E evaluator, Class<E> clazz, ItemName evaluatorName) throws SchemaException {
if (expression == null) {
expression = new ExpressionType();
Expand All @@ -590,12 +590,13 @@ private static <E extends Object> void updateExpressionEvaluator(
removeEvaluatorByName(expression, evaluatorName);

if (evaluator == null) {
return;
return null;
}

JAXBElement<E> element =
new JAXBElement<>(evaluatorName, clazz, evaluator);
expression.expressionEvaluator(element);
return expression;
}

public static void updateGenerateExpressionValue(
Expand Down
Expand Up @@ -25,4 +25,14 @@ public static String getTargetNameOrOid(ObjectReferenceType ref) {
}
return ref.getOid();
}

public static boolean referencesOidEqual(ObjectReferenceType ref1, ObjectReferenceType ref2) {
if (ref1 == null || ref2 == null) {
return false;
}
if (ref1.getOid() == null || ref2.getOid() == null) {
return false;
}
return ref1.getOid().equals(ref2.getOid());
}
}
Expand Up @@ -582,10 +582,17 @@ private void compileObjectType(CompiledObjectCollectionView existingView, GuiObj
private void compileActions(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType) {
List<GuiActionType> newActions = objectListViewType.getAction();
for (GuiActionType newAction : newActions) {
// TODO: check for action duplication/override
existingView.getActions().add(newAction); // No need to clone, CompiledObjectCollectionView is not prism
// TODO: check for action override
if (!alreadyExist(existingView, newAction)) {
existingView.getActions().add(newAction); // No need to clone, CompiledObjectCollectionView is not prism
}
}
}

private boolean alreadyExist(CompiledObjectCollectionView view, GuiActionType action) {
return view.getActions()
.stream()
.anyMatch(a -> ObjectReferenceTypeUtil.referencesOidEqual(a.getTaskTemplateRef(), action.getTaskTemplateRef()));
}

private void compileColumns(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType) {
Expand Down

0 comments on commit 16994d1

Please sign in to comment.