Skip to content

Commit

Permalink
Schema for object lists (adminGuiConfig). Just search box mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik authored and KaterynaHonchar committed Mar 1, 2017
1 parent 170b551 commit f3f52ea
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 8 deletions.
Expand Up @@ -19,6 +19,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DashboardLayoutType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DashboardWidgetType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectListType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectListsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFormType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFormsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
Expand Down Expand Up @@ -66,12 +68,21 @@ private static void applyAdminGuiConfiguration(AdminGuiConfigurationType composi
if (adminGuiConfiguration.getPreferredDataLanguage() != null) {
composite.setPreferredDataLanguage(adminGuiConfiguration.getPreferredDataLanguage());
}
if (adminGuiConfiguration.getObjectLists() != null) {
if (composite.getObjectLists() == null) {
composite.setObjectLists(adminGuiConfiguration.getObjectLists().clone());
} else {
for (GuiObjectListType objectList: adminGuiConfiguration.getObjectLists().getObjectList()) {
mergeList(composite.getObjectLists(), objectList);
}
}
}
if (adminGuiConfiguration.getObjectForms() != null) {
if (composite.getObjectForms() == null) {
composite.setObjectForms(adminGuiConfiguration.getObjectForms().clone());
} else {
for (ObjectFormType objectForm: adminGuiConfiguration.getObjectForms().getObjectForm()) {
replaceForm(composite.getObjectForms(), objectForm.clone());
replaceForm(composite.getObjectForms(), objectForm);
}
}
}
Expand All @@ -94,9 +105,22 @@ private static void replaceForm(ObjectFormsType objectForms, ObjectFormType newF
iterator.remove();
}
}
objectForms.getObjectForm().add(newForm);
objectForms.getObjectForm().add(newForm.clone());
}

private static void mergeList(GuiObjectListsType objectLists, GuiObjectListType newList) {
// We support only the default object lists now, so simply replace the existing definition with the
// latest definition. We will need a more sophisticated merging later.
Iterator<GuiObjectListType> iterator = objectLists.getObjectList().iterator();
while (iterator.hasNext()) {
GuiObjectListType currentList = iterator.next();
if (currentList.getType().equals(newList.getType())) {
iterator.remove();
}
}
objectLists.getObjectList().add(newList.clone());
}

private static void mergeWidget(DashboardLayoutType compositeDashboard, DashboardWidgetType newWidget) {
String newWidgetIdentifier = newWidget.getIdentifier();
DashboardWidgetType compositeWidget = findWidget(compositeDashboard, newWidgetIdentifier);
Expand Down
117 changes: 117 additions & 0 deletions infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd
Expand Up @@ -10735,6 +10735,19 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="objectLists" type="tns:GuiObjectListsType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
<p>
Specifies the set of pages that are used for displaying lists of objects
such as Users, Roles, Orgs, ...
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.4</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="objectForms" type="tns:ObjectFormsType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -10761,6 +10774,7 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<!-- TODO: role catalog views: define collections (additional views), default search type, etc. -->
<xsd:element name="defaultTimezone" type="xsd:string" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -13781,7 +13795,110 @@
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="sequence" type="tns:SequenceType" />

<xsd:complexType name="GuiObjectListsType">
<xsd:annotation>
<xsd:documentation>
Specifies the set of pages that are used for displaying lists of objects
such as Users, Roles, Orgs, ...
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="objectList" type="tns:GuiObjectListType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="includeDefaultLists" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true">
<xsd:annotation>
<xsd:documentation>
If set to true then all the default lists will be displayed (all users, all roles, ...)
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<!-- Note: ObjectListType already defined in API types -->
<xsd:complexType name="GuiObjectListType">
<xsd:annotation>
<xsd:documentation>
Specifies the page used to list specific object type or object collection.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<!-- TODO: now we support only default object lists (all user, all role). But later we will need to
add name, label (display name) and menu label for this list.
We will also need a reference to which menu section we want to display it. E.g. We would
like to display role catalog under "roles", even though it is in fact org tree. -->
<xsd:element name="type" type="xsd:QName" minOccurs="1" maxOccurs="1"/>
<!-- TODO: refernce to object collection (MID-3517) -->
<xsd:element name="searchBoxConfiguration" type="tns:SearchBoxConfigurationType" minOccurs="0" maxOccurs="1"/>
<!-- TODO: columns to display -->
<!-- TODO: number of results per page (MID-1931) -->
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="SearchBoxConfigurationType">
<xsd:annotation>
<xsd:documentation>
Configuration of the search box (the set of input fields that control definition of search query).
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="defaultMode" type="tns:SearchBoxModeType" minOccurs="0" maxOccurs="1" default="basic"/>
<!-- TODO: default items to display for basic search -->
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="SearchBoxModeType">
<xsd:annotation>
<xsd:documentation>
The mode of the search box.
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="basic">
<xsd:annotation>
<xsd:documentation>
Basic search mode. Ability to select the items and specify values for them.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="BASIC"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="advanced">
<xsd:annotation>
<xsd:documentation>
Advanced search mode. Ability to create complex query using a query language.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="ADVANCED"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="fulltext">
<xsd:annotation>
<xsd:documentation>
Fulltext search mode. Single input field used to search over several fields.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="FULLTEXT"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>


<!-- ============================================================== -->
<!-- FORMS -->
Expand Down
Expand Up @@ -458,7 +458,7 @@ public void test130GetAdminGuiConfig() throws Exception {
result.computeStatus();
TestUtil.assertSuccess(result);

assertAdminGuiConfigurations(adminGuiConfiguration, 0, 1, 1, 0);
assertAdminGuiConfigurations(adminGuiConfiguration, 0, 1, 3, 1, 0);

RichHyperlinkType link = adminGuiConfiguration.getUserDashboardLink().get(0);
assertEquals("Bad link label", "Foo", link.getLabel());
Expand Down
Expand Up @@ -542,7 +542,7 @@ public void test100JackRolePirate() throws Exception {
assertNotAuthorized(principal, AUTZ_LOOT_URL, null);
assertNotAuthorized(principal, AUTZ_COMMAND_URL);

assertAdminGuiConfigurations(principal, 1, 2, 2, 2);
assertAdminGuiConfigurations(principal, 1, 2, 3, 2, 2);
}

@Test
Expand All @@ -568,7 +568,7 @@ public void test109JackUnassignRolePirate() throws Exception {
assertNotAuthorized(principal, AUTZ_LOOT_URL);
assertNotAuthorized(principal, AUTZ_COMMAND_URL);

assertAdminGuiConfigurations(principal, 0, 1, 1, 0);
assertAdminGuiConfigurations(principal, 0, 1, 3, 1, 0);
}

@Test
Expand Down
Expand Up @@ -218,6 +218,26 @@
<targetUrl>/foo</targetUrl>
<label>Foo</label>
</userDashboardLink>
<objectLists>
<objectList>
<type>UserType</type>
<searchBoxConfiguration>
<defaultMode>basic</defaultMode>
</searchBoxConfiguration>
</objectList>
<objectList>
<type>RoleType</type>
<searchBoxConfiguration>
<defaultMode>fulltext</defaultMode>
</searchBoxConfiguration>
</objectList>
<objectList>
<type>ServiceType</type>
<searchBoxConfiguration>
<defaultMode>advanced</defaultMode>
</searchBoxConfiguration>
</objectList>
</objectLists>
<objectForms>
<objectForm>
<type>RoleType</type>
Expand Down
Expand Up @@ -3487,21 +3487,30 @@ protected void assertNoAuthorizations(MidPointPrincipal principal) {
}

protected AdminGuiConfigurationType assertAdminGuiConfigurations(MidPointPrincipal principal, int expectedMenuLinks,
int expectedDashboardLinks, int expectedObjectForms, int expecteduserDashboardWidgets) {
int expectedDashboardLinks, int expectedObjectLists, int expectedObjectForms, int expecteduserDashboardWidgets) {
AdminGuiConfigurationType adminGuiConfiguration = principal.getAdminGuiConfiguration();
display("Admin GUI config for "+principal.getUsername(), adminGuiConfiguration);
assertAdminGuiConfigurations(adminGuiConfiguration,
expectedMenuLinks, expectedDashboardLinks, expectedObjectForms, expecteduserDashboardWidgets);
expectedMenuLinks, expectedDashboardLinks, expectedObjectLists, expectedObjectForms, expecteduserDashboardWidgets);
return adminGuiConfiguration;
}

protected void assertAdminGuiConfigurations(AdminGuiConfigurationType adminGuiConfiguration,
int expectedMenuLinks, int expectedDashboardLinks, int expectedObjectForms, int expecteduserDashboardWidgets) {
int expectedMenuLinks, int expectedDashboardLinks, int expectedObjectLists, int expectedObjectForms, int expecteduserDashboardWidgets) {
assertNotNull("No admin GUI configuration", adminGuiConfiguration);
assertEquals("Wrong number of menu links in",
expectedMenuLinks, adminGuiConfiguration.getAdditionalMenuLink().size());
assertEquals("Wrong number of menu links in",
expectedDashboardLinks, adminGuiConfiguration.getUserDashboardLink().size());
if ( adminGuiConfiguration.getObjectLists() == null ) {
if (expectedObjectLists != 0) {
AssertJUnit.fail("Wrong number of object lists in user dashboard admin GUI configuration, expected "
+ expectedObjectLists + " but there was none");
}
} else {
assertEquals("Wrong number of object lists in admin GUI configuration",
expectedObjectLists, adminGuiConfiguration.getObjectLists().getObjectList().size());
}
assertEquals("Wrong number of object forms in admin GUI configuration",
expectedObjectForms, adminGuiConfiguration.getObjectForms().getObjectForm().size());
if ( adminGuiConfiguration.getUserDashboard() == null) {
Expand Down

0 comments on commit f3f52ea

Please sign in to comment.