|
1 | 1 | package de.fraunhofer.ipa.rossystem.deployment |
2 | 2 |
|
3 | | -import rossystem.RosSystem |
4 | | -import java.util.List |
5 | | -import componentInterface.ComponentInterface |
6 | | -import ros.impl.PackageImpl |
7 | | -import ros.Dependency |
8 | | -import ros.PackageDependency |
9 | | -import java.util.ArrayList |
10 | | -import java.util.Set |
11 | | -import java.util.HashSet |
12 | 3 | import rossystem.ComponentStack |
13 | | -import de.fraunhofer.ipa.rossystem.generator.GeneratorHelpers |
| 4 | +import rossystem.RosSystem |
| 5 | +import de.fraunhofer.ipa.rossystem.deployment.DeploymentHelpers |
14 | 6 |
|
15 | 7 | class RosInstallCompiler { |
16 | | - |
17 | | - PackageImpl component_package; |
18 | | - Set<String> Repos; |
19 | | - List<CharSequence> PkgsList |
20 | | - List<ComponentInterface> ComponentsList |
21 | | - GeneratorHelpers generator_helper = new GeneratorHelpers() |
| 8 | + DeploymentHelpers generator_helper = new DeploymentHelpers() |
| 9 | + val repo_info = newLinkedHashMap('local_name' -> null, 'branch' -> null, 'uri' -> null) |
22 | 10 |
|
23 | | - def create_repo_link (String repo)''' |
24 | | -«IF repo.indexOf(":", repo.indexOf(":") + 1) > 1» |
25 | | -- git: {local-name: «repo.substring(0,repo.lastIndexOf(':')).substring(repo.lastIndexOf("/") + 1).replace(".git","")», uri: «repo.substring(0,repo.lastIndexOf(':'))», version: «repo.substring(repo.lastIndexOf(':') + 1)»} |
26 | | -«ELSE» |
27 | | -- git: {local-name: «repo.substring(repo.lastIndexOf("/") + 1).replace(".git","")», uri: «repo»} |
28 | | -«ENDIF» |
| 11 | +def get_repo_info(String repo){ |
| 12 | + repo_info.put('branch', null) |
| 13 | + repo_info.put('local_name', null) |
| 14 | + repo_info.put('uri', null) |
| 15 | + if(repo.indexOf(":", repo.indexOf(":") + 1) > 1) { |
| 16 | + repo_info.put('branch', repo.substring(repo.lastIndexOf(':')+ 1)) |
| 17 | + val uri = repo.substring(0,repo.lastIndexOf(':')) |
| 18 | + repo_info.put('uri', uri) |
| 19 | + repo_info.put('local_name', uri.substring(uri.lastIndexOf("/") + 1).replace(".git","")) |
| 20 | + } |
| 21 | + else { |
| 22 | + repo_info.put('branch', null) |
| 23 | + repo_info.put('uri', repo) |
| 24 | + repo_info.put('local_name', repo.substring(repo.lastIndexOf("/") + 1).replace(".git","")) |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | + def create_repo_link (String repo) |
| 29 | + '''«get_repo_info(repo)» |
| 30 | +- git: {local-name: «repo_info.get('local_name')», uri: «repo_info.get('uri')»«IF repo_info.get('branch')!==null», version: «repo_info.get('branch')»«ENDIF»} |
29 | 31 | ''' |
30 | 32 | |
31 | 33 | def compile_toRosInstall (RosSystem system,ComponentStack stack) '''«generator_helper.init_pkg()» |
32 | | -«IF stack===null»«FOR repo:system.listOfRepos» |
| 34 | +«IF stack===null»«FOR repo: generator_helper.listOfRepos(system)» |
33 | 35 | «create_repo_link(repo)» |
34 | 36 | «ENDFOR» |
35 | | -«ELSE»«FOR repo:stack.listOfRepos» |
| 37 | +«ELSE»«FOR repo: generator_helper.listOfRepos(stack)» |
36 | 38 | «create_repo_link(repo)» |
37 | 39 | «ENDFOR» |
38 | 40 | «ENDIF» |
39 | 41 | ''' |
40 | | -
|
41 | | - def Set<String> listOfRepos(Object subsystem) { |
42 | | - PkgsList = new ArrayList() |
43 | | - ComponentsList = new ArrayList<ComponentInterface>(); |
44 | | - if (subsystem.class.toString.contains("RosSystemImpl")){ |
45 | | - ComponentsList = (subsystem as RosSystem).rosComponent |
46 | | - } else if (subsystem.class.toString.contains("ComponentStackImpl")) { |
47 | | - ComponentsList = (subsystem as ComponentStack).rosComponent |
48 | | - } |
49 | | - |
50 | | - |
51 | | - Repos = new HashSet<String>(); |
52 | | - for (ComponentInterface component: ComponentsList){ |
53 | | - component_package = null; |
54 | | - component_package = generator_helper.get_pkg(component); |
55 | | - if (component_package !== null){ |
56 | | - if (component_package.fromGitRepo !== null){ |
57 | | - Repos.add(component_package.fromGitRepo); |
58 | | - } |
59 | | - if (!component_package.dependency.empty){ |
60 | | - for (Dependency depend: component_package.dependency){ |
61 | | - if ((depend as PackageDependency).package !== null){ |
62 | | - if ((depend as PackageDependency).package.fromGitRepo !== null){ |
63 | | - Repos.add((depend as PackageDependency).package.fromGitRepo); |
64 | | - } |
65 | | - } |
66 | | - } |
67 | | - }}} |
68 | | - return Repos; |
69 | | - } |
70 | | -
|
71 | 42 | } |
0 commit comments