Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.translator.tojava; |
| 18 | |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 19 | import org.onosproject.yangutils.datamodel.RpcNotificationContainer; |
| 20 | import org.onosproject.yangutils.datamodel.YangAugment; |
| 21 | import org.onosproject.yangutils.datamodel.YangInput; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.YangOutput; |
| 24 | import org.onosproject.yangutils.datamodel.YangRpc; |
| 25 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 26 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModuleTranslator; |
| 27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModuleTranslator; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 28 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 29 | |
| 30 | import java.io.File; |
| 31 | import java.io.IOException; |
| 32 | import java.util.List; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 33 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 35 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
| 36 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 38 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 39 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 41 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 42 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 43 | import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; |
| 44 | import static org.onosproject.yangutils.utils.UtilConstants.INPUT; |
| 45 | import static org.onosproject.yangutils.utils.UtilConstants.OUTPUT; |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 46 | import static org.onosproject.yangutils.utils.UtilConstants.Operation.ADD; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 47 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 48 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 49 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 50 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 51 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 52 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 53 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 54 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 55 | |
| 56 | /** |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 57 | * Represents implementation of java service code fragments temporary |
| 58 | * implementations. Maintains the temp files required specific for service |
| 59 | * and manager java snippet generation. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 60 | */ |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 61 | public class TempJavaServiceFragmentFiles extends TempJavaFragmentFiles { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 62 | |
| 63 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 64 | * File name for rpc method. |
| 65 | */ |
| 66 | private static final String RPC_INTERFACE_FILE_NAME = "Rpc"; |
| 67 | |
| 68 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 69 | * Temporary file handle for rpc interface. |
| 70 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 71 | private final File rpcInterfaceTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Java file handle for rpc interface file. |
| 75 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 76 | private File serviceJavaFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 77 | |
| 78 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 79 | * Creates an instance of temporary java code fragment. |
| 80 | * |
| 81 | * @param javaFileInfo generated file information |
| 82 | * @throws IOException when fails to create new file handle |
| 83 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 84 | TempJavaServiceFragmentFiles(JavaFileInfoTranslator javaFileInfo) |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 85 | throws IOException { |
| 86 | setJavaExtendsListHolder(new JavaExtendsListHolder()); |
| 87 | setJavaImportData(new JavaImportData()); |
| 88 | setJavaFileInfo(javaFileInfo); |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 89 | setAbsoluteDirPath(getAbsolutePackagePath( |
| 90 | getJavaFileInfo().getBaseCodeGenPath(), |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 91 | getJavaFileInfo().getPackageFilePath())); |
| 92 | addGeneratedTempFile(RPC_INTERFACE_MASK); |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 93 | rpcInterfaceTempFileHandle = getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 97 | * Returns rpc method's temporary file handle. |
| 98 | * |
| 99 | * @return temporary file handle |
| 100 | */ |
| 101 | public File getRpcInterfaceTempFileHandle() { |
| 102 | return rpcInterfaceTempFileHandle; |
| 103 | } |
| 104 | |
| 105 | /** |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 106 | * Constructs java code exit. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 107 | * |
| 108 | * @param fileType generated file type |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 109 | * @param curNode current YANG node |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 110 | * @throws IOException when fails to generate java files |
| 111 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 112 | @Override |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 113 | public void generateJavaFile(int fileType, YangNode curNode) |
| 114 | throws IOException { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 115 | |
| 116 | addResolvedAugmentedDataNodeImports(curNode); |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 117 | List<String> imports = ((JavaCodeGeneratorInfo) curNode) |
| 118 | .getTempJavaCodeFragmentFiles().getServiceTempFiles() |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 119 | .getJavaImportData().getImports(); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 120 | createPackage(curNode); |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 121 | boolean notification = false; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 122 | if (curNode instanceof YangJavaModuleTranslator) { |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 123 | if (!((YangJavaModuleTranslator) curNode).getNotificationNodes() |
| 124 | .isEmpty()) { |
| 125 | notification = true; |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 126 | } |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 127 | } else if (curNode instanceof YangJavaSubModuleTranslator) { |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 128 | if (!((YangJavaSubModuleTranslator) curNode).getNotificationNodes() |
| 129 | .isEmpty()) { |
| 130 | notification = true; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 131 | } |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 132 | } |
| 133 | |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 134 | if (notification) { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 135 | addListenersImport(curNode, imports, ADD); |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 136 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 137 | |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 138 | serviceJavaFileHandle = getJavaFileHandle(getJavaClassName(SERVICE)); |
| 139 | generateServiceInterfaceFile(serviceJavaFileHandle, curNode, imports); |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 140 | |
| 141 | // Close all the file handles. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 142 | freeTemporaryResources(false); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Adds rpc string information to applicable temp file. |
| 147 | * |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 148 | * @param inAttr RPCs input node attribute info |
| 149 | * @param outAttr RPCs output node attribute info |
| 150 | * @param rpcName name of the rpc function |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 151 | * @throws IOException IO operation fail |
| 152 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 153 | private void addRpcString(JavaAttributeInfo inAttr, JavaAttributeInfo outAttr, |
| 154 | String rpcName) throws IOException { |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 155 | String rpcInput = null; |
| 156 | String rpcOutput = VOID; |
| 157 | String rpcIn = EMPTY_STRING; |
| 158 | if (inAttr != null) { |
| 159 | rpcInput = getCapitalCase(inAttr.getAttributeName()); |
| 160 | } |
| 161 | if (outAttr != null) { |
| 162 | rpcOutput = getCapitalCase(outAttr.getAttributeName()); |
| 163 | } |
| 164 | if (rpcInput != null) { |
| 165 | rpcIn = RPC_INPUT_VAR_NAME; |
| 166 | } |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 167 | appendToFile(rpcInterfaceTempFileHandle, |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 168 | generateJavaDocForRpc(rpcName, rpcIn, rpcOutput) + |
| 169 | getRpcServiceMethod(rpcName, rpcInput, rpcOutput)); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Adds the JAVA rpc snippet information. |
| 174 | * |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 175 | * @param inAttr RPCs input node attribute info |
| 176 | * @param outAttr RPCs output node attribute info |
| 177 | * @param rpcName name of the rpc function |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 178 | * @throws IOException IO operation fail |
| 179 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 180 | public void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo inAttr, |
| 181 | JavaAttributeInfo outAttr, |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 182 | String rpcName) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 183 | throws IOException { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 184 | addRpcString(inAttr, outAttr, rpcName); |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Creates an attribute info object corresponding to a data model node and |
| 189 | * return it. |
| 190 | * |
| 191 | * @param childNode child data model node(input / output) for which the java code generation |
| 192 | * is being handled |
| 193 | * @param parentNode parent node (module / sub-module) in which the child node is an attribute |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 194 | * @param rpcName rpc name |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 195 | * @return AttributeInfo attribute details required to add in temporary |
| 196 | * files |
| 197 | */ |
| 198 | public JavaAttributeInfo getChildNodeAsAttributeInParentService( |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 199 | YangNode childNode, YangNode parentNode, String rpcName) { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 200 | |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 201 | JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) childNode) |
| 202 | .getJavaFileInfo(); |
| 203 | String childNodeName = fileInfo.getJavaName(); |
| 204 | if (childNodeName == null) { |
| 205 | if (childNode instanceof YangInput) { |
| 206 | childNodeName = rpcName + HYPHEN + INPUT; |
| 207 | } else { |
| 208 | childNodeName = rpcName + HYPHEN + OUTPUT; |
| 209 | } |
| 210 | childNodeName = getCamelCase(childNodeName, null); |
| 211 | } |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 212 | /* |
| 213 | * Get the import info corresponding to the attribute for import in |
| 214 | * generated java files or qualified access |
| 215 | */ |
| 216 | JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = |
| 217 | getQualifiedTypeInfoOfCurNode(childNode, |
| 218 | getCapitalCase(childNodeName)); |
| 219 | if (!(parentNode instanceof TempJavaCodeFragmentFilesContainer)) { |
| 220 | throw new TranslatorException("Parent node does not have file info"); |
| 221 | } |
| 222 | |
| 223 | boolean isQualified = addImportToService(qualifiedTypeInfo, parentNode); |
| 224 | return getAttributeInfoForTheData(qualifiedTypeInfo, childNodeName, |
| 225 | null, isQualified, false); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Adds to service class import list. |
| 230 | * |
| 231 | * @param importInfo import info |
| 232 | * @return true or false |
| 233 | */ |
| 234 | private boolean addImportToService( |
| 235 | JavaQualifiedTypeInfoTranslator importInfo, YangNode curNode) { |
| 236 | JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) curNode) |
| 237 | .getJavaFileInfo(); |
| 238 | String name = fileInfo.getJavaName(); |
| 239 | String clsInfo = importInfo.getClassInfo(); |
| 240 | |
| 241 | StringBuilder className = new StringBuilder() |
| 242 | .append(getCapitalCase(name)) |
| 243 | .append(SERVICE); |
| 244 | return clsInfo.contentEquals(SERVICE) || clsInfo.contentEquals(className) || |
| 245 | getJavaImportData().addImportInfo(importInfo, className.toString(), |
| 246 | fileInfo.getPackage()); |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Adds augmented rpc methods to service temp file. |
| 251 | * |
| 252 | * @param module root node |
| 253 | * @throws IOException when fails to do IO operations |
| 254 | */ |
| 255 | public void addAugmentedRpcMethod(RpcNotificationContainer module) |
| 256 | throws IOException { |
| 257 | JavaAttributeInfo in = null; |
| 258 | JavaAttributeInfo out = null; |
| 259 | YangNode rpcChild; |
| 260 | YangRpc rpc; |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 261 | String rpcName; |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 262 | YangInput input; |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 263 | |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 264 | for (YangAugment info : module.getAugmentList()) { |
| 265 | input = (YangInput) info.getAugmentedNode(); |
| 266 | |
| 267 | if (input != null) { |
| 268 | rpc = (YangRpc) input.getParent(); |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 269 | if (!validateForIntraFile(module, (RpcNotificationContainer) rpc |
| 270 | .getParent())) { |
| 271 | rpcChild = rpc.getChild(); |
| 272 | |
| 273 | rpcName = getCamelCase(rpc.getName(), null); |
| 274 | while (rpcChild != null) { |
| 275 | if (rpcChild instanceof YangInput) { |
| 276 | in = getChildNodeAsAttributeInParentService( |
| 277 | rpcChild, (YangNode) module, rpcName); |
| 278 | } |
| 279 | if (rpcChild instanceof YangOutput) { |
| 280 | out = getChildNodeAsAttributeInParentService( |
| 281 | rpcChild, (YangNode) module, rpcName); |
| 282 | } |
| 283 | rpcChild = rpcChild.getNextSibling(); |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 284 | } |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 285 | addJavaSnippetInfoToApplicableTempFiles(in, out, rpcName); |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 286 | } |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 287 | } |
| 288 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 289 | } |
| 290 | |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame^] | 291 | private boolean validateForIntraFile(RpcNotificationContainer parent, |
| 292 | RpcNotificationContainer curModule) { |
| 293 | return parent.getPrefix().equals(curModule.getPrefix()); |
| 294 | } |
| 295 | |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 296 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 297 | * Removes all temporary file handles. |
| 298 | * |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 299 | * @param errorOccurred flag indicating error |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 300 | * @throws IOException when failed to delete the temporary files |
| 301 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 302 | @Override |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 303 | public void freeTemporaryResources(boolean errorOccurred) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 304 | throws IOException { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 305 | closeFile(serviceJavaFileHandle, errorOccurred); |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 306 | closeFile(rpcInterfaceTempFileHandle); |
Gaurav Agrawal | 3b57f36 | 2016-09-07 13:16:35 +0530 | [diff] [blame] | 307 | closeFile(getGetterInterfaceTempFileHandle()); |
| 308 | closeFile(getSetterInterfaceTempFileHandle()); |
| 309 | closeFile(getSetterImplTempFileHandle()); |
| 310 | super.freeTemporaryResources(errorOccurred); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 311 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 312 | } |