Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-16768
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-p-pickering authored Jan 10, 2025
2 parents a4e03df + 0caa211 commit d221b70
Show file tree
Hide file tree
Showing 133 changed files with 732 additions and 1,620 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ public interface CategoryService {
*/
Category getCategoryByName(String name, UserDetails userDetails);

/**
* Returns all DataElementCategories.
*
* @return a list of all DataElementCategories.
*/
List<Category> getAllDataElementCategories();

/**
* Retrieves all DataElementCategories of dimension type disaggregation.
*
Expand Down Expand Up @@ -330,24 +323,6 @@ SetValuedMap<String, String> getCategoryOptionOrganisationUnitsAssociations(
*/
List<CategoryCombo> getAttributeCategoryCombos();

/**
* Validates the category combo. Possible return values are:
*
* <p>
*
* <ul>
* <li>category_combo_is_null
* <li>category_combo_must_have_at_least_one_category
* <li>category_combo_cannot_have_duplicate_categories
* <li>categories_must_have_at_least_one_category_option
* <li>categories_cannot_share_category_options
* </ul>
*
* @param categoryCombo the category combo to validate.
* @return null if valid, non-empty string if invalid.
*/
String validateCategoryCombo(CategoryCombo categoryCombo);

// -------------------------------------------------------------------------
// CategoryOptionCombo
// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.Immutable;
Expand Down Expand Up @@ -83,22 +85,22 @@
@JacksonXmlRootElement(localName = "identifiableObject", namespace = DxfNamespaces.DXF_2_0)
public class BaseIdentifiableObject extends BaseLinkableObject implements IdentifiableObject {
/** The database internal identifier for this Object. */
protected long id;
@Setter protected long id;

/** The unique identifier for this object. */
@AuditAttribute protected String uid;
@Setter @AuditAttribute protected String uid;

/** The unique code for this object. */
@AuditAttribute protected String code;
@Setter @AuditAttribute protected String code;

/** The name of this object. Required and unique. */
protected String name;
@Setter protected String name;

/** The date this object was created. */
protected Date created;
@Setter protected Date created;

/** The date this object was last updated. */
protected Date lastUpdated;
@Setter protected Date lastUpdated;

/** Set of the dynamic attributes values that belong to this data element. */
@AuditAttribute private AttributeValues attributeValues = AttributeValues.empty();
Expand All @@ -110,7 +112,7 @@ public class BaseIdentifiableObject extends BaseLinkableObject implements Identi
* Cache for object translations, where the cache key is a combination of locale and translation
* property, and value is the translated value.
*/
private Map<String, String> translationCache = new ConcurrentHashMap<>();
private final Map<String, String> translationCache = new ConcurrentHashMap<>();

/** User who created this object. This field is immutable and must not be updated. */
@Immutable protected User createdBy;
Expand All @@ -119,13 +121,13 @@ public class BaseIdentifiableObject extends BaseLinkableObject implements Identi
protected transient Access access;

/** Users who have marked this object as a favorite. */
protected Set<String> favorites = new HashSet<>();
@Setter protected Set<String> favorites = new HashSet<>();

/** Last user updated this object. */
protected User lastUpdatedBy;
@Setter protected User lastUpdatedBy;

/** Object sharing (JSONB). */
protected Sharing sharing = new Sharing();
@Setter protected Sharing sharing = new Sharing();

// -------------------------------------------------------------------------
// Constructors
Expand Down Expand Up @@ -162,7 +164,7 @@ public BaseIdentifiableObject(IdentifiableObject identifiableObject) {
* name.
*/
@Override
public int compareTo(IdentifiableObject object) {
public int compareTo(@Nonnull IdentifiableObject object) {
if (this.getDisplayName() == null) {
return object.getDisplayName() == null ? 0 : 1;
}
Expand All @@ -182,10 +184,6 @@ public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

@Override
@JsonProperty(value = "id")
@JacksonXmlProperty(localName = "id", isAttribute = true)
Expand All @@ -196,10 +194,6 @@ public String getUid() {
return uid;
}

public void setUid(String uid) {
this.uid = uid;
}

@Override
@JsonProperty
@JacksonXmlProperty(isAttribute = true)
Expand All @@ -209,10 +203,6 @@ public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

@Override
@JsonProperty
@JacksonXmlProperty(isAttribute = true)
Expand All @@ -222,11 +212,8 @@ public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
@Sortable(whenPersisted = false)
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
@Translatable(propertyName = "name", key = "NAME")
Expand All @@ -243,10 +230,6 @@ public Date getCreated() {
return created;
}

public void setCreated(Date created) {
this.created = created;
}

@Override
@OpenApi.Property(UserPropertyTransformer.UserDto.class)
@JsonProperty
Expand All @@ -258,10 +241,6 @@ public User getLastUpdatedBy() {
return lastUpdatedBy;
}

public void setLastUpdatedBy(User lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy;
}

@Override
@JsonProperty
@JacksonXmlProperty(isAttribute = true)
Expand All @@ -271,10 +250,6 @@ public Date getLastUpdated() {
return lastUpdated;
}

public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}

public record AttributeValue(@JsonProperty Attribute attribute, @JsonProperty String value) {}

@Override
Expand Down Expand Up @@ -308,6 +283,7 @@ public String getAttributeValue(String attributeUid) {

@Gist(included = Include.FALSE)
@Override
@Sortable(value = false)
@JsonProperty
@JacksonXmlElementWrapper(localName = "translations", namespace = DxfNamespaces.DXF_2_0)
@JacksonXmlProperty(localName = "translation", namespace = DxfNamespaces.DXF_2_0)
Expand Down Expand Up @@ -387,8 +363,9 @@ public void setOwner(String userId) {
}

@Override
@Sortable(value = false)
@Gist(included = Include.FALSE)
@JsonProperty
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JacksonXmlProperty(localName = "access", namespace = DxfNamespaces.DXF_2_0)
public Access getAccess() {
return access;
Expand All @@ -407,10 +384,6 @@ public Set<String> getFavorites() {
return favorites;
}

public void setFavorites(Set<String> favorites) {
this.favorites = favorites;
}

@Override
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
Expand All @@ -422,6 +395,7 @@ public boolean isFavorite() {
}

@Override
@Sortable(value = false)
@Gist(included = Include.FALSE)
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
Expand All @@ -433,10 +407,6 @@ public Sharing getSharing() {
return sharing;
}

public void setSharing(Sharing sharing) {
this.sharing = sharing;
}

@Override
public boolean setAsFavorite(UserDetails user) {
if (this.favorites == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class BaseLinkableObject implements LinkableObject {
private transient String href;

@Override
@JsonProperty
@Sortable(value = false)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JacksonXmlProperty(isAttribute = true)
@Property(PropertyType.URL)
public String getHref() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public String toString() {
// -------------------------------------------------------------------------

@Override
@Sortable
@JsonProperty
@JacksonXmlProperty(isAttribute = true)
@PropertyRange(min = 1)
Expand All @@ -178,6 +179,7 @@ public void setShortName(String shortName) {
}

@Override
@Sortable(whenPersisted = false)
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
@Translatable(propertyName = "shortName", key = "SHORT_NAME")
Expand All @@ -186,6 +188,7 @@ public String getDisplayShortName() {
}

@Override
@Sortable
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
@PropertyRange(min = 1)
Expand All @@ -198,6 +201,7 @@ public void setDescription(String description) {
}

@Override
@Sortable(value = false)
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
@Translatable(propertyName = "description", key = "DESCRIPTION")
Expand All @@ -206,6 +210,7 @@ public String getDisplayDescription() {
}

@JsonProperty
@Sortable(whenPersisted = false)
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
@Translatable(propertyName = "formName", key = "FORM_NAME")
public String getDisplayFormName() {
Expand All @@ -217,6 +222,7 @@ public String getFormNameFallback() {
return formName != null && !formName.isEmpty() ? getFormName() : getDisplayName();
}

@Sortable
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getFormName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2024, University of Oslo
* Copyright (c) 2004-2025, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -25,39 +25,18 @@
* (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.scheduling;
package org.hisp.dhis.common;

import java.io.InputStream;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hisp.dhis.feedback.ConflictException;
import org.hisp.dhis.fileresource.FileResourceService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MimeType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @author Morten Svanæs <[email protected]>
*/
@Slf4j
@RequiredArgsConstructor
@Service
@Profile("!test")
public class JobCreationHelperForProduction implements JobCreationHelper {

private final JobConfigurationStore jobConfigurationStore;
private final FileResourceService fileResourceService;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Sortable {

@Transactional
public String create(JobConfiguration config) throws ConflictException {
return createFromConfig(config, jobConfigurationStore);
}
boolean value() default true;

@Transactional
public String create(JobConfiguration config, MimeType contentType, InputStream content)
throws ConflictException {
return createFromConfigAndInputStream(
config, contentType, content, jobConfigurationStore, fileResourceService);
}
boolean whenPersisted() default true;
}
Loading

0 comments on commit d221b70

Please sign in to comment.