Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jan 17, 2020
2 parents 2656675 + 4a48950 commit a289983
Show file tree
Hide file tree
Showing 50 changed files with 811 additions and 439 deletions.
Expand Up @@ -111,6 +111,8 @@ public class GuiStyleConstants {
public static final String CLASS_ICON_NO_OBJECTS = "fa fa-times";
public static final String CLASS_ICON_ACTIVATION_ACTIVE = "fa fa-check";
public static final String CLASS_ICON_ACTIVATION_INACTIVE = "fa fa-times";
public static final String CLASS_ICON_RESOURCE_BROKEN = "fa fa-exclamation";
public static final String CLASS_ICON_RESOURCE_UNKNOWN = "fa fa-question";
public static final String CLASS_ICON_ASSIGNMENTS = "fa fa-bank";
public static final String CLASS_SHADOW_ICON_REQUEST = "fa fa-pencil-square-o";
public static final String CLASS_ICON_TACHOMETER = "fa fa-tachometer";
Expand Down
Expand Up @@ -151,12 +151,16 @@ private ITab createSchemaEditor() {

@Override
public WebMarkupContainer getPanel(String panelId) {
XmlEditorPanel xmlEditorPanel = new XmlEditorPanel(panelId, createXmlEditorModel());
// quick fix: now changes from XmlEditorPanel are not saved anyhow
//(e.g. by clicking Finish button in wizard). For now,
//panel is made disabled for editing
AceEditor aceEditor = (AceEditor) xmlEditorPanel.get(ID_ACE_EDITOR);
aceEditor.setReadonly(true);
XmlEditorPanel xmlEditorPanel = new XmlEditorPanel(panelId, createXmlEditorModel()) {

// quick fix: now changes from XmlEditorPanel are not saved anyhow
//(e.g. by clicking Finish button in wizard). For now,
@Override
protected boolean isEditEnabled() {
return false;
}
};

return xmlEditorPanel;
}
};
Expand Down
Expand Up @@ -7,6 +7,7 @@

package com.evolveum.midpoint.web.component.wizard.resource.component;

import com.evolveum.midpoint.web.component.util.EnableBehaviour;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
Expand All @@ -32,6 +33,11 @@ protected void onInitialize() {

protected void initLayout() {
AceEditor editor = new AceEditor(ID_ACE_EDITOR, getModel());
editor.setReadonly(!isEditEnabled());
add(editor);
}

protected boolean isEditEnabled() {
return true;
}
}
Expand Up @@ -9,6 +9,7 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
Expand All @@ -21,21 +22,13 @@
public class ResourceSummaryPanel extends ObjectSummaryPanel<ResourceType> {
private static final long serialVersionUID = 1L;

private static final String ID_UP_DOWN_TAG = "upDownTag";
private IModel<ResourceType> model;

public ResourceSummaryPanel(String id, IModel<ResourceType> model, ModelServiceLocator serviceLocator) {
super(id, ResourceType.class, model, serviceLocator);
}

// @Override
// protected void onBeforeRender() {
// super.onBeforeRender();
// }

@Override
protected List<SummaryTag<ResourceType>> getSummaryTagComponentList(){
boolean down = ResourceTypeUtil.isDown(getModelObject());
AvailabilityStatusType availability = ResourceTypeUtil.getLastAvailabilityStatus(getModelObject());

List<SummaryTag<ResourceType>> summaryTagList = new ArrayList<>();

Expand All @@ -44,12 +37,24 @@ protected List<SummaryTag<ResourceType>> getSummaryTagComponentList(){

@Override
protected void initialize(ResourceType object) {
if (!down) {
setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_ACTIVE);
setLabel(getString("ResourceSummaryPanel.UP"));
} else {
setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_INACTIVE);
setLabel(getString("ResourceSummaryPanel.DOWN"));
if (availability== null) {
setIconCssClass(GuiStyleConstants.CLASS_ICON_RESOURCE_UNKNOWN);
setLabel(getString("ResourceSummaryPanel.UNKNOWN"));
return;
}
setLabel(getString(ResourceSummaryPanel.this.getString(availability)));
switch(availability) {
case UP:
setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_ACTIVE);
break;
case DOWN:
setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_INACTIVE);
break;
case BROKEN:
setIconCssClass(GuiStyleConstants.CLASS_ICON_RESOURCE_BROKEN);
break;


}
}
};
Expand Down
Expand Up @@ -67,7 +67,8 @@ public interface PrismSerializer<T> {
PrismSerializer<T> options(@Nullable SerializationOptions options);

/**
* These items will be skipped during serialization.
* These items will be skipped during serialization. If present, their original presence is indicated
* by the "incomplete" flag.
*
* @param itemNames Names of items to be skipped.
* @return Serializer with the items to be skipped set.
Expand Down
Expand Up @@ -15,7 +15,12 @@ public class SerializationOptions implements Cloneable {
private boolean serializeCompositeObjects;
private boolean serializeReferenceNames;
private boolean serializeReferenceNamesForNullOids;

/**
* Should we skip index-only items? Their values will be omitted and they will be marked as incomplete.
*/
private boolean skipIndexOnly;

private ItemNameQualificationStrategy itemNameQualificationStrategy;

/**
Expand Down
Expand Up @@ -1016,7 +1016,7 @@ public static void assertRefFilter(ObjectFilter objectFilter, QName expectedFilt
assertPathEquivalent("Wrong filter path", path, filter.getFullPath());
}

// Local version of JUnit assers to avoid pulling JUnit dependecy to main
// Local version of JUnit asserts to avoid pulling JUnit dependency to main

static void assertNotNull(String string, Object object) {
assert object != null : string;
Expand Down Expand Up @@ -1241,4 +1241,9 @@ public static <O extends Objectable> void assertEquivalent(String message, ItemP
}
}

public static void assertIncomplete(PrismObject<?> object, ItemPath itemPath) {
Item<?, ?> item = object.findItem(itemPath);
assertNotNull("No " + itemPath + " in " + object, item);
assertTrue(itemPath + " is not incomplete in " + object, item.isIncomplete());
}
}
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.prism.xnode;

/**
* This is a marker that a given prism item is incomplete.
*
* EXPERIMENTAL
*/
public interface IncompleteMarkerXNode extends XNode {
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -369,6 +369,9 @@ public <IV extends PrismValue,ID extends ItemDefinition> boolean merge(Item<IV,I
changed = true;
}
}
if (item.isIncomplete()) {
existingItem.setIncomplete(true);
}
return changed;
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -83,11 +83,6 @@ interface RootXNodeHandler {
* TODO
*
* Not supported for NullLexicalProcessor, though.
* @param roots
* @param aggregateElementName
* @param context
* @return
* @throws SchemaException
*/
@NotNull
T write(@NotNull List<RootXNodeImpl> roots, @Nullable QName aggregateElementName, @Nullable SerializationContext context) throws SchemaException;
Expand Down
Expand Up @@ -233,6 +233,10 @@ private XNodeImpl parseElementContent(@NotNull Element element, QName knownEleme
} else {
node = parseElementContentToMap(element);
}
} else if (DOMUtil.isMarkedAsIncomplete(element)) {
// Note that it is of no use to check for "incomplete" on non-leaf elements. In XML the incomplete attribute
// must be attached to an empty element.
node = new IncompleteMarkerXNodeImpl();
} else {
node = parsePrimitiveElement(element);
}
Expand Down Expand Up @@ -278,7 +282,7 @@ private MapXNodeImpl parseElementContentToMap(Element element) throws SchemaExce
}

private boolean isList(@NotNull Element element, @NotNull QName elementName, @Nullable QName xsiType) {
String isListAttribute = DOMUtil.getAttribute(element, new QName(DOMUtil.IS_LIST_ATTRIBUTE_NAME));
String isListAttribute = DOMUtil.getAttribute(element, DOMUtil.IS_LIST_ATTRIBUTE_NAME);
if (StringUtils.isNotEmpty(isListAttribute)) {
return Boolean.parseBoolean(isListAttribute);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum and contributors
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -17,6 +17,7 @@
import com.evolveum.midpoint.prism.impl.xnode.RootXNodeImpl;
import com.evolveum.midpoint.prism.impl.xnode.SchemaXNodeImpl;
import com.evolveum.midpoint.prism.impl.xnode.XNodeImpl;
import com.evolveum.midpoint.prism.xnode.IncompleteMarkerXNode;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
Expand Down Expand Up @@ -120,23 +121,25 @@ private Element serializeInternal(@NotNull RootXNodeImpl rootxnode, Element pare
DOMUtil.setXsiType(topElement, setQNamePrefixExplicitIfNeeded(typeQName));
}
XNodeImpl subnode = rootxnode.getSubnode();
if (subnode instanceof PrimitiveXNodeImpl){
if (subnode instanceof PrimitiveXNodeImpl) {
serializePrimitiveElementOrAttribute((PrimitiveXNodeImpl) subnode, topElement, rootElementName, false);
return DOMUtil.getFirstChildElement(topElement);
}
if (subnode instanceof MapXNodeImpl) {
// at this point we can put frequently used namespaces (e.g. c, t, q, ri) into the document to eliminate their use
// on many places inside the doc (MID-2198)
DOMUtil.setNamespaceDeclarations(topElement, getNamespacePrefixMapper().getNamespacesDeclaredByDefault());
serializeMap((MapXNodeImpl) subnode, topElement);
} else if (subnode.isHeterogeneousList()) {
DOMUtil.setNamespaceDeclarations(topElement, getNamespacePrefixMapper().getNamespacesDeclaredByDefault());
serializeExplicitList((ListXNodeImpl) subnode, topElement);
} else {
throw new SchemaException("Sub-root xnode is not a map nor an explicit list, cannot serialize to XML (it is "+subnode+")");
if (subnode instanceof MapXNodeImpl) {
// at this point we can put frequently used namespaces (e.g. c, t, q, ri) into the document to eliminate their use
// on many places inside the doc (MID-2198)
DOMUtil.setNamespaceDeclarations(topElement, getNamespacePrefixMapper().getNamespacesDeclaredByDefault());
serializeMap((MapXNodeImpl) subnode, topElement);
} else if (subnode.isHeterogeneousList()) {
DOMUtil.setNamespaceDeclarations(topElement, getNamespacePrefixMapper().getNamespacesDeclaredByDefault());
serializeExplicitList((ListXNodeImpl) subnode, topElement);
} else {
throw new SchemaException(
"Sub-root xnode is not a map nor an explicit list, cannot serialize to XML (it is " + subnode + ")");
}
addDefaultNamespaceDeclaration(topElement);
return topElement;
}
addDefaultNamespaceDeclaration(topElement);
return topElement;
}

/**
Expand Down Expand Up @@ -176,15 +179,19 @@ private void serializeSubnode(XNodeImpl xsubnode, Element parentElement, QName e
if (xsubnode == null) {
return;
}
if (xsubnode instanceof RootXNodeImpl) {
if (xsubnode instanceof IncompleteMarkerXNode) {
Element element = createElement(elementName, parentElement);
DOMUtil.setAttributeValue(element, DOMUtil.IS_INCOMPLETE_ATTRIBUTE_NAME, "true");
parentElement.appendChild(element);
} else if (xsubnode instanceof RootXNodeImpl) {
Element element = createElement(elementName, parentElement);
appendCommentIfPresent(element, xsubnode);
parentElement.appendChild(element);
serializeSubnode(((RootXNodeImpl) xsubnode).getSubnode(), element, ((RootXNodeImpl) xsubnode).getRootElementName());
} else if (xsubnode instanceof MapXNodeImpl) {
Element element = createElement(elementName, parentElement);
appendCommentIfPresent(element, xsubnode);
if (xsubnode.isExplicitTypeDeclaration() && xsubnode.getTypeQName() != null){
if (xsubnode.isExplicitTypeDeclaration() && xsubnode.getTypeQName() != null) {
DOMUtil.setXsiType(element, setQNamePrefixExplicitIfNeeded(xsubnode.getTypeQName()));
}
parentElement.appendChild(element);
Expand Down

0 comments on commit a289983

Please sign in to comment.