TAPI topology creation for 100GE Transponder
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / validation / checks / TopoConstraintCheck.java
1 /*
2  * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.tapi.validation.checks;
9
10 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
11 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.TopologyConstraint;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 public final class TopoConstraintCheck {
16
17     private static final Logger LOG = LoggerFactory.getLogger(TopoConstraintCheck.class);
18
19     private TopoConstraintCheck() {
20     }
21
22     public static boolean checkString(String value) {
23         return ((value != null) && (value.compareTo("") != 0));
24     }
25
26     public static ComplianceCheckResult check(TopologyConstraint tc) {
27         boolean result = true;
28         String message = "";
29         LOG.info("tc = {}", tc.toString());
30         if (tc.getAvoidTopology() == null || tc.getExcludeLink() == null || tc.getExcludeNode() == null || tc
31             .getExcludePath() == null || tc.getIncludeLink() == null || tc.getIncludeNode() == null || tc
32                 .getIncludePath() == null || tc.getIncludeTopology() == null || tc
33                     .getPreferredTransportLayer() == null) {
34             LOG.info("tc is null");
35             result = true;
36             message = "Topology constraints are not managet yet";
37         } else if (tc.getAvoidTopology().isEmpty() || tc.getExcludeLink().isEmpty() || tc.getExcludeNode().isEmpty()
38             || tc
39                 .getExcludePath().isEmpty() || tc.getIncludeLink().isEmpty() || tc.getIncludeNode().isEmpty() || tc
40                     .getIncludePath().isEmpty() || tc.getIncludeTopology().isEmpty() || tc.getPreferredTransportLayer()
41                         .isEmpty()) {
42             result = false;
43             message = "Topology constraints are not managet yet";
44         }
45
46         return new ComplianceCheckResult(result, message);
47     }
48 }