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.contentviews.formatter; |
35 |
|
|
36 |
|
import info.magnolia.jcr.util.NodeTypes; |
37 |
|
import info.magnolia.jcr.util.NodeUtil; |
38 |
|
import info.magnolia.ui.vaadin.integration.jcr.JcrNodeAdapter; |
39 |
|
import info.magnolia.ui.workbench.column.AbstractColumnFormatter; |
40 |
|
import info.magnolia.ui.workbench.column.definition.PropertyColumnDefinition; |
41 |
|
|
42 |
|
import javax.inject.Inject; |
43 |
|
import javax.jcr.Node; |
44 |
|
import javax.jcr.RepositoryException; |
45 |
|
|
46 |
|
import org.slf4j.Logger; |
47 |
|
import org.slf4j.LoggerFactory; |
48 |
|
|
49 |
|
import com.vaadin.data.Item; |
50 |
|
import com.vaadin.ui.Table; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
|
|
| 85.7% |
Uncovered Elements: 3 (21) |
Complexity: 7 |
Complexity Density: 0.54 |
|
56 |
|
public class FolderNameColumnFormatter extends AbstractColumnFormatter<PropertyColumnDefinition> { |
57 |
|
|
58 |
|
private Logger log = LoggerFactory.getLogger(getClass()); |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
4 |
@Inject... |
61 |
|
public FolderNameColumnFormatter(PropertyColumnDefinition definition) { |
62 |
4 |
super(definition); |
63 |
|
} |
64 |
|
|
|
|
| 83.3% |
Uncovered Elements: 3 (18) |
Complexity: 6 |
Complexity Density: 0.5 |
|
65 |
4 |
@Override... |
66 |
|
public Object generateCell(Table source, Object itemId, Object columnId) { |
67 |
4 |
Item item = source.getItem(itemId); |
68 |
4 |
if (item instanceof JcrNodeAdapter) { |
69 |
1 |
JcrNodeAdapter nodeAdapter = (JcrNodeAdapter)item; |
70 |
1 |
Node node = nodeAdapter.getJcrItem(); |
71 |
1 |
try { |
72 |
1 |
if (NodeUtil.isNodeType(node, NodeTypes.Folder.NAME)) { |
73 |
1 |
return node.getName(); |
74 |
|
} |
75 |
|
} catch (RepositoryException e) { |
76 |
0 |
log.error("Failed to determine folder name: ", e); |
77 |
0 |
return ""; |
78 |
|
} |
79 |
|
} |
80 |
3 |
if (item != null && item.getItemProperty(columnId) != null) { |
81 |
1 |
return item.getItemProperty(columnId).getValue(); |
82 |
|
} |
83 |
2 |
return ""; |
84 |
|
} |
85 |
|
} |