Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5dbb24adc887fb655a5340d1fc72762ee7ec1827 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*********************************************************************
 * Copyright (c) 2014 Boeing
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Boeing - initial API and implementation
 **********************************************************************/

package org.eclipse.osee.orcs.db.internal.search.handlers;

import java.util.List;
import org.eclipse.osee.framework.core.enums.SqlTable;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeNotExists;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;

/**
 * @author John Misinco
 */
public class RelationTypeNotExistsSqlHandler extends AbstractRelationSqlHandler<CriteriaRelationTypeNotExists> {

   @Override
   public void addPredicates(AbstractSqlWriter writer) {
      super.addPredicates(writer);

      writer.write("NOT EXISTS (SELECT 1 FROM ");
      String relAlias = writer.writeTable(SqlTable.RELATION_TABLE);
      writer.write(", ");
      String txsAlias = writer.writeTable(SqlTable.TXS_TABLE);
      writer.write(" WHERE ");
      writer.writeEqualsParameterAnd(relAlias, "rel_link_type_id", criteria.getType());

      List<String> aliases = writer.getAliases(SqlTable.ARTIFACT_TABLE);
      int aSize = aliases.size();
      for (int index = 0; index < aSize; index++) {
         String artAlias = aliases.get(index);

         writer.write("(");
         writer.writeEquals(relAlias, "a_art_id", artAlias, "art_id");
         writer.write(" OR ");
         writer.writeEquals(relAlias, "b_art_id", artAlias, "art_id");
         writer.write(")");

         if (index + 1 < aSize) {
            writer.writeAndLn();
         }
      }
      writer.writeAndLn();
      writer.writeEquals(relAlias, txsAlias, "gamma_id");
      writer.writeAndLn();
      writer.writeTxBranchFilter(txsAlias);
      writer.write(")");
   }
}

Back to the top