All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.ird.observe.services.service.referential.ReferentialService Maven / Gradle / Ivy

The newest version!
package fr.ird.observe.services.service.referential;

/*-
 * #%L
 * ObServe Toolkit :: Service
 * %%
 * Copyright (C) 2017 - 2021 Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import fr.ird.observe.dto.BusinessDto;
import fr.ird.observe.dto.ToolkitIdLabel;
import fr.ird.observe.dto.form.Form;
import fr.ird.observe.dto.reference.ReferentialDtoReference;
import fr.ird.observe.dto.reference.ReferentialDtoReferenceSet;
import fr.ird.observe.dto.referential.ReferentialDto;
import fr.ird.observe.dto.result.SaveResultDto;
import fr.ird.observe.security.Permission;
import fr.ird.observe.services.service.ObserveService;
import fr.ird.observe.services.spi.MethodCredential;
import fr.ird.observe.spi.referential.MissingReferentialRequest;
import fr.ird.observe.spi.referential.MissingReferentialResult;
import fr.ird.observe.spi.referential.ReferentialIds;
import fr.ird.observe.spi.referential.differential.DifferentialMetaModel;
import fr.ird.observe.spi.referential.differential.DifferentialModelBuilder;
import io.ultreia.java4all.http.spi.Delete;
import io.ultreia.java4all.http.spi.Get;
import io.ultreia.java4all.http.spi.Nullable;
import io.ultreia.java4all.http.spi.Post;
import io.ultreia.java4all.http.spi.Write;
import org.nuiton.topia.persistence.script.TopiaSqlScript;

import java.util.Date;
import java.util.Locale;
import java.util.Set;

/**
 * Created on 16/08/15.
 *
 * @author Tony Chemit - [email protected]
 */
public interface ReferentialService extends ObserveService {

    static DifferentialModelBuilder createDifferentialModelBuilder(Locale locale, ReferentialService leftReferentialService, ReferentialService rightReferentialService) {
        return new DifferentialModelBuilder(
                locale,
                leftReferentialService::differentialMetaModel,
                leftReferentialService::loadDtoList,
                rightReferentialService::loadDtoList,
                leftReferentialService::getEnabledReferentialLabelSet,
                rightReferentialService::getEnabledReferentialLabelSet
        );
    }

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     ReferentialDtoReferenceSet getReferenceSet(Class type, @Nullable Date lastUpdateDate);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     Set getEnabledReferentialLabelSet(Class type);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     Set> getReferentialReferenceSets(ReferenceSetsRequest request);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     Set getReferentialDtoSet(Class type, @Nullable Date lastUpdateDate, String... ids);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     D loadDto(Class type, String id);

    @Post
    @MethodCredential(Permission.READ_REFERENTIAL)
     Set loadDtoList(Class type);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     Set loadIds(Class type);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     Form loadForm(Class type, String id);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     R loadReference(Class type, String id);

    @MethodCredential(Permission.READ_REFERENTIAL)
    @Get
    DifferentialMetaModel differentialMetaModel();

    @Get
    @MethodCredential(Permission.WRITE_REFERENTIAL)
     Form preCreate(Class type);

    @Write
    @Post
    @MethodCredential(Permission.WRITE_REFERENTIAL)
     SaveResultDto save(D bean);

    @Write
    @Delete
    @MethodCredential(Permission.ALL)
     void delete(Class type, String id);

    @Post
    @Write
    @MethodCredential(Permission.ALL)
     void replaceReference(Class beanType, String idToReplace, String replaceId);

    @Post
    @Write
    @MethodCredential(Permission.ALL)
     void changeId(Class beanType, String id, String newId);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     boolean exists(Class type, String id);

    @Get
    @MethodCredential(Permission.READ_REFERENTIAL)
     Set getNaturalIds(Class type);

    @Post
    @MethodCredential(Permission.READ_REFERENTIAL)
    ReferentialIds getReferentialIds();

    @Post(useMultiPartForm = true)
    @MethodCredential(Permission.READ_ALL)
    MissingReferentialResult computeMissingReferential(MissingReferentialRequest request);

    @Post(useMultiPartForm = true)
    @Write
    @MethodCredential(Permission.READ_ALL_AND_WRITE_DATA)
    void insertMissingReferential(TopiaSqlScript sqlContent);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy