-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: PI Disaggregation objects [DHIS2-18745] #19601
Draft
jimgrace
wants to merge
2
commits into
dhis2:DHIS2-18745
Choose a base branch
from
jimgrace:DHIS2-18745
base: DHIS2-18745
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramCategoryMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright (c) 2004-2022, 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.program; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import lombok.NoArgsConstructor; | ||
import org.hisp.dhis.category.Category; | ||
import org.hisp.dhis.common.BaseIdentifiableObject; | ||
import org.hisp.dhis.common.DxfNamespaces; | ||
import org.hisp.dhis.common.MetadataObject; | ||
|
||
/** | ||
* Defines one of the ways in which a {@link ProgramIndicator} for a {@link Program} can return | ||
* category option combinations or attribute option combinations based on filters for the options in | ||
* the option combinations | ||
* | ||
* @author Jim Grace | ||
*/ | ||
@NoArgsConstructor | ||
@JacksonXmlRootElement(localName = "programCategoryMapping", namespace = DxfNamespaces.DXF_2_0) | ||
public class ProgramCategoryMapping extends BaseIdentifiableObject implements MetadataObject { | ||
|
||
/** The program for this category mapping */ | ||
private Program program; | ||
|
||
/** The category for this category mapping */ | ||
private Category category; | ||
|
||
/** The category mapping name, must be unique within a program and category */ | ||
private String mappingName; | ||
|
||
/** The category option mappings for this program, category, and name */ | ||
private Set<ProgramCategoryOptionMapping> optionMappings = new HashSet<>(); | ||
|
||
// ------------------------------------------------------------------------- | ||
// Getters and setters | ||
// ------------------------------------------------------------------------- | ||
|
||
@JsonProperty | ||
@JsonSerialize(as = BaseIdentifiableObject.class) | ||
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) | ||
public Program getProgram() { | ||
return program; | ||
} | ||
|
||
public void setProgram(Program program) { | ||
this.program = program; | ||
} | ||
|
||
@JsonProperty | ||
@JsonSerialize(as = BaseIdentifiableObject.class) | ||
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) | ||
public Category getCategory() { | ||
return category; | ||
} | ||
|
||
public void setCategory(Category category) { | ||
this.category = category; | ||
} | ||
|
||
@JsonProperty | ||
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) | ||
public String getMappingName() { | ||
return mappingName; | ||
} | ||
|
||
public void setMappingName(String mappingName) { | ||
this.mappingName = mappingName; | ||
} | ||
|
||
@JsonProperty | ||
@JacksonXmlElementWrapper(localName = "optionMappings", namespace = DxfNamespaces.DXF_2_0) | ||
@JacksonXmlProperty(localName = "optionMapping", namespace = DxfNamespaces.DXF_2_0) | ||
public Set<ProgramCategoryOptionMapping> getOptionMappings() { | ||
return optionMappings; | ||
} | ||
|
||
public void setOptionMappings(Set<ProgramCategoryOptionMapping> optionMappings) { | ||
this.optionMappings = optionMappings; | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramCategoryMappingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2004-2022, 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.program; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Jim Grace | ||
*/ | ||
public interface ProgramCategoryMappingService { | ||
// ------------------------------------------------------------------------- | ||
// ProgramCategoryMapping | ||
// ------------------------------------------------------------------------- | ||
|
||
/** | ||
* Adds a {@link ProgramCategoryMapping} | ||
* | ||
* @param programCategoryMapping The ProgramCategoryMapping to add. | ||
* @return A generated unique id of the added {@link ProgramCategoryMapping}. | ||
*/ | ||
long saveProgramCategoryMapping(ProgramCategoryMapping programCategoryMapping); | ||
|
||
/** | ||
* Deletes a {@link ProgramCategoryMapping}. | ||
* | ||
* @param programCategoryMapping the ProgramCategoryMapping to delete. | ||
*/ | ||
void deleteProgramCategoryMapping(ProgramCategoryMapping programCategoryMapping); | ||
|
||
/** | ||
* Updates an {@link ProgramCategoryMapping}. | ||
* | ||
* @param programCategoryMapping the ProgramCategoryMapping to update. | ||
*/ | ||
void updateProgramCategoryMapping(ProgramCategoryMapping programCategoryMapping); | ||
|
||
/** | ||
* Returns a {@link ProgramCategoryMapping}. | ||
* | ||
* @param id the id of the ProgramCategoryMapping to return. | ||
* @return the ProgramCategoryMapping with the given id | ||
*/ | ||
ProgramCategoryMapping getProgramCategoryMapping(long id); | ||
|
||
/** | ||
* Returns the {@link ProgramCategoryMapping} with the given UID. | ||
* | ||
* @param uid the UID. | ||
* @return the ProgramCategoryMapping with the given UID, or null if no match. | ||
*/ | ||
ProgramCategoryMapping getProgramCategoryMapping(String uid); | ||
|
||
/** | ||
* Retrieve all ProgramCategoryMappings associated with the given {@link Program}. | ||
* | ||
* @param program the Program. | ||
* @return a list og ProgramCategoryMappings. | ||
*/ | ||
List<ProgramCategoryMapping> getProgramCategoryMappingsByProgram(Program program); | ||
} |
45 changes: 45 additions & 0 deletions
45
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramCategoryMappingStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2004-2022, 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.program; | ||
|
||
import java.util.List; | ||
import org.hisp.dhis.common.IdentifiableObjectStore; | ||
|
||
/** | ||
* @author Jim Grace | ||
*/ | ||
public interface ProgramCategoryMappingStore | ||
extends IdentifiableObjectStore<ProgramCategoryMapping> { | ||
/** | ||
* Returns a list of program category mappings for a program | ||
* | ||
* @param program the program for which the category mappings are desired | ||
* @return a list of program category mappings for that program | ||
*/ | ||
List<ProgramCategoryMapping> getByProgram(Program program); | ||
} |
104 changes: 104 additions & 0 deletions
104
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramCategoryOptionMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (c) 2004-2022, 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.program; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
import lombok.NoArgsConstructor; | ||
import org.hisp.dhis.category.CategoryOption; | ||
import org.hisp.dhis.common.DxfNamespaces; | ||
import org.hisp.dhis.common.EmbeddedObject; | ||
|
||
/** | ||
* Defines a filter expression fragment for a {@link CategoryOption} within a {@link | ||
* ProgramCategoryMapping} to identify an option in a category option combination or an attribute | ||
* option combination to be returned as a program indicator dimension. | ||
* | ||
* @author Jim Grace | ||
*/ | ||
@NoArgsConstructor | ||
@JacksonXmlRootElement(localName = "optionMappings", namespace = DxfNamespaces.DXF_2_0) | ||
public class ProgramCategoryOptionMapping implements EmbeddedObject { | ||
|
||
/** The database internal identifier for this Object. */ | ||
private int id; | ||
|
||
/** The program category mapping */ | ||
private ProgramCategoryMapping categoryMapping; | ||
|
||
/** The category option to be mapped */ | ||
private CategoryOption categoryOption; | ||
|
||
/** The filter for this category option */ | ||
private String filter; | ||
|
||
// ------------------------------------------------------------------------- | ||
// Getters and setters | ||
// ------------------------------------------------------------------------- | ||
|
||
@JsonIgnore | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
@JsonProperty | ||
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) | ||
public ProgramCategoryMapping getCategoryMapping() { | ||
return categoryMapping; | ||
} | ||
|
||
public void setCategoryMapping(ProgramCategoryMapping categoryMapping) { | ||
this.categoryMapping = categoryMapping; | ||
} | ||
|
||
@JsonProperty | ||
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) | ||
public CategoryOption getCategoryOption() { | ||
return categoryOption; | ||
} | ||
|
||
public void setCategoryOption(CategoryOption categoryOption) { | ||
this.categoryOption = categoryOption; | ||
} | ||
|
||
@JsonProperty | ||
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) | ||
public String getFilter() { | ||
return filter; | ||
} | ||
|
||
public void setFilter(String filter) { | ||
this.filter = filter; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
id
column is mapped asbigint
in database so I think it should belong
java type.