fr.ird.observe.services.service.referential.UnidirectionalSynchronizeContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of toolkit-service Show documentation
Show all versions of toolkit-service Show documentation
ObServe Toolkit Service module
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.referential.ReferentialDto;
import fr.ird.observe.spi.referential.synchro.BothSidesSqlRequest;
import fr.ird.observe.spi.referential.synchro.UnidirectionalCallbackRequests;
import org.nuiton.topia.persistence.script.TopiaSqlScript;
import java.nio.file.Path;
import java.util.Optional;
import java.util.Set;
/**
* Created on 12/07/16.
*
* @author Tony Chemit - [email protected]
* @since 5.0
*/
public class UnidirectionalSynchronizeContext {
private final Set> usedTypes;
private final BothSidesSqlRequest.Builder sqlRequestsBuilder;
private final UnidirectionalCallbackRequests callbackRequests;
private Path sqlScriptPath;
private TopiaSqlScript sqlScript;
UnidirectionalSynchronizeContext(Set> usedTypes, BothSidesSqlRequest.Builder sqlRequestsBuilder, UnidirectionalCallbackRequests callbackRequests) {
this.usedTypes = usedTypes;
this.sqlRequestsBuilder = sqlRequestsBuilder;
this.callbackRequests = callbackRequests;
}
public Set> getUsedTypes() {
return usedTypes;
}
BothSidesSqlRequest.Builder getSqlRequestsBuilder() {
return sqlRequestsBuilder;
}
public UnidirectionalCallbackRequests getCallbackRequests() {
return callbackRequests;
}
public boolean isNeedCallback() {
return callbackRequests.isNotEmpty();
}
public Optional getSqlScript() {
return Optional.ofNullable(sqlScript);
}
public void setSqlScript(TopiaSqlScript sqlScript) {
this.sqlScript = sqlScript;
}
public Path getSqlScriptPath() {
return sqlScriptPath;
}
public void setSqlScriptPath(Path sqlScriptPath) {
this.sqlScriptPath = sqlScriptPath;
}
public void finish(SynchronizeService leftService) {
Optional sqlScript = getSqlScript();
sqlScript.ifPresent(script -> leftService.applySql(script, SynchronizeService.SIMPLE_REFERENTIAL_SYNCHRONISATION));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy