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 |
|
package info.magnolia.module.googlesitemap.app.subapp.sitemapdetail.pages; |
35 |
|
|
36 |
|
import info.magnolia.context.MgnlContext; |
37 |
|
import info.magnolia.event.EventBus; |
38 |
|
import info.magnolia.i18nsystem.SimpleTranslator; |
39 |
|
import info.magnolia.module.googlesitemap.GoogleSiteMapConfiguration; |
40 |
|
import info.magnolia.module.googlesitemap.app.subapp.sitemapdetail.base.SiteMapContentView; |
41 |
|
import info.magnolia.module.googlesitemap.app.subapp.sitemapdetail.base.SiteMapDetailPresenter; |
42 |
|
import info.magnolia.module.googlesitemap.bean.SiteMapEntry; |
43 |
|
import info.magnolia.module.googlesitemap.service.SiteMapService; |
44 |
|
import info.magnolia.repository.RepositoryConstants; |
45 |
|
import info.magnolia.ui.api.app.SubAppEventBus; |
46 |
|
|
47 |
|
import java.util.ArrayList; |
48 |
|
import java.util.Iterator; |
49 |
|
import java.util.List; |
50 |
|
|
51 |
|
import javax.inject.Inject; |
52 |
|
import javax.inject.Named; |
53 |
|
import javax.jcr.Node; |
54 |
|
import javax.jcr.PropertyIterator; |
55 |
|
import javax.jcr.RepositoryException; |
56 |
|
|
57 |
|
|
58 |
|
@link |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 15 |
Complexity Density: 0.62 |
|
60 |
|
public class SiteMapPagesPresenter extends SiteMapDetailPresenter<SiteMapPagesView.Listener> implements SiteMapPagesView.Listener { |
61 |
|
|
62 |
|
private List<SiteMapEntry> expandedEntries = new ArrayList<SiteMapEntry>(); |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0
|
@Inject... |
65 |
|
public SiteMapPagesPresenter(SiteMapPagesView view, SiteMapService service, @Named(SubAppEventBus.NAME) EventBus eventBus, SimpleTranslator translator) { |
66 |
0
|
super(view, service, eventBus, translator); |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0
|
@Override... |
70 |
|
public SiteMapContentView start() { |
71 |
0
|
return super.start(); |
72 |
|
} |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
0
|
@Override... |
75 |
|
protected SiteMapContentView.Listener getListener() { |
76 |
0
|
return this; |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
79 |
0
|
@Override... |
80 |
|
public void onEntryExpanded(SiteMapEntry entry) { |
81 |
0
|
if (!expandedEntries.contains(entry)) { |
82 |
0
|
expandedEntries.add(entry); |
83 |
|
} |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
0
|
@Override... |
87 |
|
public void onEntryCollapsed(SiteMapEntry entry) { |
88 |
0
|
expandedEntries.remove(entry); |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
91 |
0
|
@Override... |
92 |
|
public void edit(Node siteMapNode) { |
93 |
0
|
super.edit(siteMapNode); |
94 |
0
|
restoreExpandedEntries(); |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
0
|
@Override... |
98 |
|
public String getLabel() { |
99 |
0
|
return getTranslator().translate("siteMaps.pages.label"); |
100 |
|
} |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.44 |
|
102 |
0
|
@Override... |
103 |
|
protected List<SiteMapEntry> fetchSiteMapEntries(Node node) { |
104 |
0
|
List<SiteMapEntry> entries = new ArrayList<SiteMapEntry>(); |
105 |
0
|
try { |
106 |
0
|
PropertyIterator it = node.getNode(GoogleSiteMapConfiguration.SITE_DIALOG_CONFIGURATION_NAME).getProperties(); |
107 |
0
|
while (it.hasNext()) { |
108 |
0
|
String siteId = it.nextProperty().getString(); |
109 |
0
|
try { |
110 |
0
|
Node site = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE).getNode(siteId); |
111 |
0
|
entries.addAll(service.getSiteMapBeanForSite(site, true)); |
112 |
|
} catch (Exception e) { |
113 |
|
|
114 |
|
} |
115 |
|
} |
116 |
|
} catch (RepositoryException e) { |
117 |
|
|
118 |
|
} |
119 |
0
|
return entries; |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
122 |
0
|
private void restoreExpandedEntries() {... |
123 |
0
|
Iterator<SiteMapEntry> it = expandedEntries.iterator(); |
124 |
0
|
while (it.hasNext()) { |
125 |
0
|
SiteMapEntry entry = it.next(); |
126 |
0
|
if (siteContainer.containsId(entry)) { |
127 |
0
|
((SiteMapPagesView)getView()).expandEntry(entry); |
128 |
|
} else { |
129 |
0
|
it.remove(); |
130 |
|
} |
131 |
|
} |
132 |
|
} |
133 |
|
} |