
org.nuiton.topia.templates.sql.plan.TopiaEntitySqlDeletePlanBuilderForEntryPoint Maven / Gradle / Ivy
package org.nuiton.topia.templates.sql.plan;
/*-
* #%L
* Toolkit :: Templates
* %%
* Copyright (C) 2017 - 2024 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 org.nuiton.topia.service.sql.model.AbstractTopiaEntitySqlTable;
import org.nuiton.topia.service.sql.model.TopiaEntitySqlAssociationTable;
import org.nuiton.topia.service.sql.model.TopiaEntitySqlDescriptor;
import org.nuiton.topia.service.sql.model.TopiaEntitySqlDescriptors;
import org.nuiton.topia.service.sql.model.TopiaEntitySqlSelector;
import org.nuiton.topia.service.sql.model.TopiaEntitySqlSimpleAssociationTable;
import org.nuiton.topia.service.sql.model.TopiaEntitySqlTable;
import java.util.List;
/**
* Created on 28/02/2022.
*
* @author Tony Chemit - [email protected]
* @since 1.67
*/
public class TopiaEntitySqlDeletePlanBuilderForEntryPoint extends TopiaEntitySqlDeletePlanBuilder {
public TopiaEntitySqlDeletePlanBuilderForEntryPoint(TopiaEntitySqlDescriptors entityDescriptor) {
super(entityDescriptor);
}
@Override
protected void startConsumeTable(TopiaEntitySqlDescriptor descriptor) {
TopiaEntitySqlTable table = descriptor.getTable();
List associations = descriptor.getAssociations();
List simpleAssociations = descriptor.getSimpleAssociations();
int selectorIndex = 0;
for (TopiaEntitySqlSelector selector : table.getSelectors()) {
addTableDeleteSql(table, selector, descriptor.isNoPath());
if (associations != null) {
for (TopiaEntitySqlAssociationTable association : associations) {
startConsumeAssociationTable(selector, descriptor, association, selectorIndex);
}
}
if (simpleAssociations != null) {
for (TopiaEntitySqlSimpleAssociationTable association : simpleAssociations) {
startConsumeAssociationTable(selector, descriptor, association, selectorIndex);
}
}
selectorIndex++;
}
}
protected void startConsumeAssociationTable(TopiaEntitySqlSelector selector, TopiaEntitySqlDescriptor descriptor, AbstractTopiaEntitySqlTable table, int selectorIndex) {
addAssociationTask(table.getSchemaAndTableName(), SqlHelper.newDeleteStatementSql(descriptor, table, selector, table.getSelectors().get(selectorIndex)));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy