Skip to content

Commit

Permalink
feat: Applied changes from feature branch [DHIS2-18239]
Browse files Browse the repository at this point in the history
  • Loading branch information
larshelge committed Nov 1, 2024
1 parent c37f3ac commit efdb439
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@
import org.hisp.dhis.common.MetadataObject;
import org.hisp.dhis.dashboard.design.ItemConfig;
import org.hisp.dhis.dashboard.design.Layout;
import org.hisp.dhis.dashboard.embedded.EmbeddedDashboard;

/**
* Encapsulates information about an embedded dashboard. An embedded dashboard is typically loaded
* from an external provider.
*
* @author Lars Helge Overland
*/
@NoArgsConstructor
Expand All @@ -67,6 +71,9 @@ public class Dashboard extends BaseNameableObject implements MetadataObject {
/** Allowed filter dimensions (if any) which may be used for the dashboard. */
private List<String> allowedFilters = new ArrayList<>();

/** Optional, only set if this dashboard is embedded and loaded from an external provider. */
private EmbeddedDashboard embedded;

// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
Expand Down Expand Up @@ -146,4 +153,14 @@ public List<String> getAllowedFilters() {
public void setAllowedFilters(List<String> allowedFilters) {
this.allowedFilters = allowedFilters;
}

@JsonProperty
@JacksonXmlProperty(namespace = DXF_2_0)
public EmbeddedDashboard getEmbedded() {
return embedded;
}

public void setEmbedded(EmbeddedDashboard embedded) {
this.embedded = embedded;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
package org.hisp.dhis.dashboard;

/**
* Encapsulates type of dashboard item.
*
* @author Lars Helge Overland
*/
public enum DashboardItemType {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2004-2024, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.dashboard.embedded;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/** Encapsulates metadata for an embedded and externally provided dashboard. */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class EmbeddedDashboard implements Serializable {
/** Provider of embedded dashboards. */
@JsonProperty private EmbeddedProvider provider;

/** Identifier for embedded dashboard. */
@JsonProperty private String id;

/** Customization options for embedded dashboard. */
@JsonProperty private EmbeddedOptions options;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2004-2024, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.dashboard.embedded;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* Encapsulates customization options for embedded dashboards.
*
* @author Lars Helge Overland
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class EmbeddedOptions implements Serializable {
/** Hide tab. Applies to Superset. */
@JsonProperty private boolean hideTab;

/** Hide the chart controls. Applies to Superset. */
@JsonProperty private boolean hideChartControls;

/** Filter options. Applies to Superset. */
@JsonProperty private FilterOptions filters;

/** Show the filters panel. Applies to Superset. */
@JsonProperty private boolean showFilters;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2004-2024, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.dashboard.embedded;

/**
* Enumeration of providers for embedded dashboards.
*
* @author Lars Helge Overland
*/
public enum EmbeddedProvider {
SUPERSET;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2004-2024, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.dashboard.embedded;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class FilterOptions implements Serializable {
/** Whether filter sidebar should be accessible when opening the dashboard. */
@JsonProperty private boolean visible;

/** Whether filter sidebar should be expanded when opening the dashboard. */
@JsonProperty private boolean expanded;
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ static boolean isTranslatable(@Nonnull String key) {
return LazySettings.isTranslatable(key);
}

/*
settings used in core
*/

/** Settings used in core */
default Locale getUiLocale() {
return asLocale("keyUiLocale", LocaleManager.DEFAULT_LOCALE);
}
Expand Down Expand Up @@ -308,6 +305,10 @@ default boolean getIncludeZeroValuesInAnalytics() {
return asBoolean("keyIncludeZeroValuesInAnalytics", false);
}

default boolean getEmbeddedDashboardsEnabled() {
return asBoolean("keyEmbeddedDashboardsEnabled", false);
}

default int getSqlViewMaxLimit() {
return asInt("keySqlViewMaxLimit", -1);
}
Expand Down Expand Up @@ -720,12 +721,7 @@ default String getGlobalShellAppName() {
return asString("globalShellAppName", "global-app-shell");
}

/*
Combinators based on several settings
*/

/** Combinators based on several settings. */
default boolean isEmailConfigured() {
return !getEmailHostName().isBlank() && !getEmailUsername().isBlank();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

<property name="allowedFilters" column="allowedfilters" type="jbList" />

<property name="embedded" column="embedded" type="jbEmbeddedDashboard" />

<!-- Sharing -->
<property name="sharing" type="jsbObjectSharing"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

/** A system setting, for use in store layer only. */
@Slf4j
@Setter
@Getter
@ToString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void testIsTranslatable() {
@Test
void testKeysWithDefaults() {
Set<String> keys = SystemSettings.keysWithDefaults();
assertEquals(135, keys.size());
assertEquals(136, keys.size());
// just check some at random
assertTrue(keys.contains("syncSkipSyncForDataChangedBefore"));
assertTrue(keys.contains("keyTrackerDashboardLayout"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

alter table "dashboard" add column if not exists "embedded" jsonb null;
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
<param name="clazz">org.hisp.dhis.dashboard.design.ItemConfig</param>
</typedef>

<typedef class="org.hisp.dhis.hibernate.jsonb.type.JsonBinaryType" name="jbEmbeddedDashboard">
<param name="clazz">org.hisp.dhis.dashboard.embedded.EmbeddedDashboard</param>
</typedef>

<typedef class="org.hisp.dhis.hibernate.jsonb.type.JsonBinaryType" name="jbTextPattern">
<param name="clazz">org.hisp.dhis.textpattern.TextPattern</param>
</typedef>
Expand Down
Loading

0 comments on commit efdb439

Please sign in to comment.