1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.admin.resources.representation.html.share;
17
18 import de.smartics.html5.jatl.Html;
19 import de.smartics.properties.admin.domain.model.ManagedApplication;
20 import de.smartics.properties.impl.config.ds.DataSourceConfiguration;
21 import de.smartics.properties.resource.domain.ArtifactId;
22
23
24
25
26
27 public final class ApplicationHtmlRenderingHelper
28 {
29
30
31
32
33
34
35
36
37
38 private final Html html;
39
40
41
42
43 private final HtmlPathHelper pathHelper;
44
45
46
47
48
49
50 private final ManagedApplication application;
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 public ApplicationHtmlRenderingHelper(final Html html,
74 final HtmlPathHelper pathHelper, final ManagedApplication application)
75 {
76 this.html = html;
77 this.pathHelper = pathHelper;
78 this.application = application;
79 }
80
81
82
83
84 public void addApplication()
85 {
86 html.dl().classAttr("dl-horizontal");
87 addApplicationId();
88 addDataSource();
89 html.end();
90 }
91
92 private void addApplicationId()
93 {
94 final ArtifactId artifactId = application.getApplicationId();
95 final String url = createArtfactUrl();
96 if (url != null)
97 {
98 html.dt().text("Application").end().dd().a().href(url)
99 .text(artifactId.toString()).end().end();
100 }
101 else
102 {
103 html.dt().text("Application").end().dd()
104 .text(application.getApplicationId().toString()).end();
105 }
106 }
107
108 private String createArtfactUrl()
109 {
110 final ArtifactId artifactId = application.getApplicationId();
111 final String url =
112 application.getRemoteRepositoryUrl() + '/'
113 + artifactId.getGroupId().replace('.', '/') + '/'
114 + artifactId.getName() + '/' + artifactId.getVersion() + '/'
115 + artifactId.getName() + '-' + artifactId.getVersion() + '.'
116 + artifactId.getArchiveType();
117 return url;
118 }
119
120 private void addDataSource()
121 {
122 final DataSourceConfiguration config = application.getDataSourceConfig();
123 if (config != null)
124 {
125 final String dsUrl = pathHelper.ds();
126 html.dt().text("Data Source").end().dd().a().href(dsUrl)
127 .text(config.toString()).end().end();
128 }
129 }
130
131
132
133 }