Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/hibernate5
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Dec 7, 2017
2 parents 7ac0267 + 76fb553 commit a4b1936
Show file tree
Hide file tree
Showing 29 changed files with 946 additions and 219 deletions.
Expand Up @@ -322,13 +322,13 @@ public SelectableBean<O> createDataObjectWrapper(O obj) {
}

@Override
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
List<ObjectOrdering> customOrdering = createCustomOrdering(sortParam);
if (customOrdering != null) {
return customOrdering;
}
return super.createObjectOrderings(sortParam);
}
return customOrdering;
}
return super.createObjectOrderings(sortParam);
}
};
if (options == null){
if (ResourceType.class.equals(type)) {
Expand Down
Expand Up @@ -29,7 +29,6 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import org.apache.commons.lang.Validate;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismObject;
Expand All @@ -45,12 +44,12 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.page.error.PageError;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;

import static com.evolveum.midpoint.schema.DefinitionProcessingOption.FULL;
import static com.evolveum.midpoint.schema.DefinitionProcessingOption.ONLY_IF_EXISTS;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;

/**
* @author lazyman
Expand Down Expand Up @@ -80,21 +79,21 @@ public class SelectableBeanObjectDataProvider<O extends ObjectType> extends Base
// private int size = Integer.MAX_VALUE;

private Class<? extends O> type;
private Collection<SelectorOptions<GetOperationOptions>> options;
private Collection<SelectorOptions<GetOperationOptions>> options;

public SelectableBeanObjectDataProvider(Component component, Class<? extends O> type, Set<? extends O> selected ) {
super(component, true, true);
public SelectableBeanObjectDataProvider(Component component, Class<? extends O> type, Set<? extends O> selected ) {
super(component, true, true);

Validate.notNull(type);
if (selected != null) {
this.selected = selected;
}
this.type = type;
}
Validate.notNull(type);
if (selected != null) {
this.selected = selected;
}
this.type = type;
}

public void clearSelectedObjects(){
selected.clear();
}
public void clearSelectedObjects(){
selected.clear();
}

public List<O> getSelectedData() {
preprocessSelectedDataInternal();
Expand Down Expand Up @@ -178,23 +177,23 @@ public Iterator<SelectableBean<O>> internalIterator(long offset, long pageSize)
List<PrismObject<? extends O>> list = (List)getModel().searchObjects(type, query, currentOptions, task, result);

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
}

for (PrismObject<? extends O> object : list) {
getAvailableData().add(createDataObjectWrapper(object.asObjectable()));
}
for (PrismObject<? extends O> object : list) {
getAvailableData().add(createDataObjectWrapper(object.asObjectable()));
}
// result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't list objects.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
return handleNotSuccessOrHandledErrorInIterator(result);
result.recordFatalError("Couldn't list objects.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
return handleNotSuccessOrHandledErrorInIterator(result);
} finally {
result.computeStatusIfUnknown();
result.computeStatusIfUnknown();
}

LOGGER.trace("end::iterator() {}", result);
return getAvailableData().iterator();
LOGGER.trace("end::iterator() {}", result);
return getAvailableData().iterator();
}

protected Iterator<SelectableBean<O>> handleNotSuccessOrHandledErrorInIterator(OperationResult result) {
Expand Down Expand Up @@ -238,7 +237,7 @@ protected int internalSize() {
try {
Task task = getPage().createSimpleTask(OPERATION_COUNT_OBJECTS);
Integer counted = getModel().countObjects(type, getQuery(), options, task, result);
count = counted == null ? 0 : counted.intValue();
count = defaultIfNull(counted, 0);
} catch (Exception ex) {
result.recordFatalError("Couldn't count objects.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
Expand All @@ -248,7 +247,8 @@ protected int internalSize() {

if (!WebComponentUtil.isSuccessOrHandledError(result)) {
getPage().showResult(result);
throw new RestartResponseException(PageError.class);
// Let us do nothing. The error will be shown on the page and a count of 0 will be used.
// Redirecting to the error page does more harm than good (see also MID-4306).
}

LOGGER.trace("end::internalSize(): {}", count);
Expand Down
Expand Up @@ -21,6 +21,7 @@
import com.evolveum.midpoint.prism.path.NameItemPathSegment;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.util.InfoTooltipBehavior;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
Expand Down Expand Up @@ -58,8 +59,8 @@ public class QNameEditorPanel extends BasePanel<ItemPathType>{
private IModel<String> localpartModel;
private IModel<String> namespaceModel;

public QNameEditorPanel(String id, IModel<ItemPathType> model, String localPartLabelKey, String localPartTooltipKey,
String namespaceLabelKey, String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired) {
public QNameEditorPanel(String id, IModel<ItemPathType> model, String localPartTooltipKey,
String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired) {
super(id, model);
this.itemPathModel = model;

Expand Down Expand Up @@ -104,7 +105,7 @@ public void detach() {
}
};

initLayout(localPartLabelKey, localPartTooltipKey, namespaceLabelKey, namespaceTooltipKey, markLocalPartAsRequired, markNamespaceAsRequired);
initLayout(localPartTooltipKey, namespaceTooltipKey, markLocalPartAsRequired, markNamespaceAsRequired);
}

private QName itemPathToQName() {
Expand Down Expand Up @@ -136,25 +137,43 @@ public IModel<ItemPathType> getModel() {
return model;
}

private void initLayout(String localPartLabelKey, String localPartTooltipKey,
String namespaceLabelKey, String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired){
private void initLayout(String localPartTooltipKey,
String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired){

Label localPartLabel = new Label(ID_LOCAL_PART_LABEL, getString(localPartLabelKey));
Label localPartLabel = new Label(ID_LOCAL_PART_LABEL, getString("SchemaHandlingStep.association.label.associationName"));
localPartLabel.setOutputMarkupId(true);
localPartLabel.setOutputMarkupPlaceholderTag(true);
localPartLabel.add(getSpecificLabelStyleAppender());
add(localPartLabel);

WebMarkupContainer localPartRequired = new WebMarkupContainer(ID_LOCAL_PART_REQUIRED);
localPartRequired.setVisible(markLocalPartAsRequired);
localPartRequired.add(new VisibleEnableBehaviour(){

private static final long serialVersionUID = 1L;

@Override
public boolean isVisible(){
return markLocalPartAsRequired;
}
});
add(localPartRequired);

Label namespaceLabel = new Label(ID_NAMESPACE_LABEL, getString(namespaceLabelKey));
Label namespaceLabel = new Label(ID_NAMESPACE_LABEL, getString("SchemaHandlingStep.association.label.associationNamespace"));
namespaceLabel.setOutputMarkupId(true);
namespaceLabel.setOutputMarkupPlaceholderTag(true);
namespaceLabel.add(getSpecificLabelStyleAppender());
add(namespaceLabel);

WebMarkupContainer namespaceRequired = new WebMarkupContainer(ID_NAMESPACE_REQUIRED);
namespaceRequired.setVisible(markNamespaceAsRequired);
namespaceRequired.add(new VisibleEnableBehaviour(){

private static final long serialVersionUID = 1L;

@Override
public boolean isVisible(){
return markNamespaceAsRequired;
}
});
add(namespaceRequired);

TextField localPart = new TextField<>(ID_LOCAL_PART, localpartModel);
Expand All @@ -176,10 +195,26 @@ private void initLayout(String localPartLabelKey, String localPartTooltipKey,
localPartTooltip.add(new AttributeAppender("data-original-title", getString(localPartTooltipKey)));
localPartTooltip.add(new InfoTooltipBehavior());
localPartTooltip.setOutputMarkupPlaceholderTag(true);
localPartTooltip.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible(){
return localPartTooltipKey != null;
}
});
add(localPartTooltip);

Label namespaceTooltip = new Label(ID_T_NAMESPACE);
namespaceTooltip.add(new AttributeAppender("data-original-title", getString(namespaceTooltipKey)));
namespaceTooltip.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible(){
return namespaceTooltipKey != null;
}
});
namespaceTooltip.add(new InfoTooltipBehavior());
namespaceTooltip.setOutputMarkupPlaceholderTag(true);
add(namespaceTooltip);
Expand Down Expand Up @@ -210,4 +245,8 @@ protected void onUpdate(AjaxRequestTarget target) {

protected void onUpdate(AjaxRequestTarget target) {
}

protected AttributeAppender getSpecificLabelStyleAppender(){
return AttributeAppender.append("style", "");
}
}
Expand Up @@ -35,6 +35,7 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.extensions.yui.calendar.DateTimeField;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
Expand Down Expand Up @@ -571,25 +572,17 @@ public String getObject() {
}
}
}, 10);
// } else if (ItemPathType.COMPLEX_TYPE.equals(valueType)) {
// definition.getNamespace()
// ValueWrapper vw = valueWrapperModel.getObject();
// if (vw != null) {
// }
// return new TextPanel<>(id, new PropertyModel<ItemPathType>(valueWrapperModel, baseExpression + ".orig"),
// String.class);
//// inputPanel = new QNameEditorPanel(id, new PropertyModel<ItemPathType>(valueWrapperModel, baseExpression),
//// "SchemaHandlingStep.association.label.associationName", "SchemaHandlingStep.association.tooltip.associationLocalPart",
//// "SchemaHandlingStep.association.label.associationNamespace", "SchemaHandlingStep.association.tooltip.associationNamespace", true, true) {
//// @Override
//// protected void onUpdate(AjaxRequestTarget target) {
////// target.add(parentStep.getAssociationList());
////// ((PageResourceWizard) getPageBase()).refreshIssues(target);
//// }
//// };
//// nonSchemaRefPanel.add(WebComponentUtil.enabledIfFalse(readOnlyModel));

}else {
} else if (ItemPathType.COMPLEX_TYPE.equals(valueType)) {
return new QNameEditorPanel(id, new PropertyModel<ItemPathType>(valueWrapperModel, baseExpression), null, null,
false, false) {
@Override
protected AttributeAppender getSpecificLabelStyleAppender() {
return AttributeAppender.append("style", "font-weight: normal !important;");
}

};

} else {
Class type = XsdTypeMapper.getXsdToJavaMapping(valueType);
if (type != null && type.isPrimitive()) {
type = ClassUtils.primitiveToWrapper(type);
Expand Down
Expand Up @@ -182,8 +182,8 @@ public List<QName> getObject() {
add(explicitRefIntegrity);

QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_ASSOCIATION_ATTRIBUTE_PANEL, new PropertyModel<ItemPathType>(getModel(), "ref"),
"SchemaHandlingStep.association.label.associationName", "SchemaHandlingStep.association.tooltip.associationLocalPart",
"SchemaHandlingStep.association.label.associationNamespace", "SchemaHandlingStep.association.tooltip.associationNamespace", true, true) {
"SchemaHandlingStep.association.tooltip.associationLocalPart", "SchemaHandlingStep.association.tooltip.associationNamespace",
true, true) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(parentStep.getAssociationList());
Expand Down

0 comments on commit a4b1936

Please sign in to comment.