org.flowstep.jdbc.model.JdbcStep Maven / Gradle / Ivy
The newest version!
/*
*
* Copyright 2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flowstep.jdbc.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.flowstep.core.CloneableList;
import org.flowstep.core.FilterDependencyLink;
import org.flowstep.core.model.StepFilter;
import org.flowstep.core.model.step.FlowStepData;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@JsonIgnoreProperties(value = {"database", "collection"})
public class JdbcStep extends FlowStepData {
private String sql;
@JsonProperty("filters")
private CloneableList filters;
public String getSql() {
return sql;
}
public void setSql(String sql) {
this.sql = sql;
}
public JdbcStep() {
super();
filters = new CloneableList<>();
}
public JdbcStep(JdbcStep step) {
super(step);
this.sql = step.sql;
this.filters = new CloneableList<>(step.filters);
}
public CloneableList getFilters() {
return filters;
}
public JdbcStep setFilters(CloneableList filters) {
this.filters = filters;
return this;
}
@Override
public List getStepDependencies() {
return getFilters().stream().map(filter -> new FilterDependencyLink(filter.getStep()).getStepName())
.filter(StringUtils::isNotBlank)
.collect(Collectors.toList());
}
public Stream getAllFilters() {
return filters.stream();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JdbcStep jdbcStep = (JdbcStep) o;
return new EqualsBuilder().appendSuper(super.equals(o)).append(sql, jdbcStep.sql).append(filters, jdbcStep.filters).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).appendSuper(super.hashCode()).append(sql).append(filters).toHashCode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy