AppResourceRepository.java

/*
 * Copyright 2026 Global Crop Diversity Trust
 * Licensed under the Apache License, Version 2.0
 * See LICENSE file in project root folder or http://www.apache.org/licenses/LICENSE-2.0
 */

package org.gringlobal.persistence;

import org.gringlobal.model.AppResource;
import org.gringlobal.spring.persistence.ExtendedJpaRepository;

import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * The Interface AppResourceRepository.
 *
 * @author Matija Obreza
 */
@Repository
public interface AppResourceRepository extends AppResourceRepositoryCustom, ExtendedJpaRepository<AppResource, Long>, QuerydslPredicateExecutor<AppResource> {

	/**
	 * Simplified AppResource for clients
	 */
	public static class AppResourceInfo {
		@JsonIgnore
		public String formName;
		@JsonIgnore
		public String resourceName;

		public String lang;
		public String valueMember;
		public String displayMember;
		public Integer sortOrder;
		public String description;
		public String properties;

		public AppResourceInfo(AppResource appResource) {
			this.lang = appResource.getSysLang().getIetfTag();
			this.formName = appResource.getFormName();
			this.resourceName = appResource.getAppResourceName();
			this.valueMember = appResource.getValueMember();
			this.description = appResource.getDescription();
			this.displayMember = appResource.getDisplayMember();
			this.properties = appResource.getProperties();
			this.sortOrder = appResource.getSortOrder();
		}
	}
}