Project

General

Profile

Download (1.76 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.vaadin.model;
2

    
3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Collection;
6
import java.util.HashMap;
7
import java.util.List;
8
import java.util.Map;
9

    
10
public class User implements Serializable {
11

    
12
	/**
13
	 *
14
	 */
15
	private static final long serialVersionUID = 1L;
16
	private final String name;
17
	private final Map<String, String> prop;
18

    
19
	public User(String name) {
20
		this.name = name;
21
		prop = new HashMap<String, String>();
22
	}
23

    
24
	public void addProp(String column, String value) {
25
		prop.put(column, value);
26
	}
27

    
28
	public Collection<String> getPropertyId() {
29
		List<String> propertyId = new ArrayList<String>();
30
		for (Map.Entry<String, String> entry : prop.entrySet()) {
31
			propertyId.add(entry.getKey());
32
		}
33
		return propertyId;
34
	}
35

    
36
	public Collection<String> getItemId() {
37
		List<String> getItemId = new ArrayList<String>();
38
		for (Map.Entry<String, String> entry : prop.entrySet()) {
39
			getItemId.add(entry.getValue());
40
		}
41
		return getItemId;
42
	}
43

    
44
    /**
45
     * @param itemId
46
     */
47
    public Object getItem(Object itemId) {
48
        String item = itemId.toString();
49
        for (Map.Entry<String, String> entry : prop.entrySet()) {
50
            if(item.equalsIgnoreCase(entry.getValue())) {
51
                return entry.getValue();
52
            }
53
        }
54
        return null;
55
    }
56

    
57
    /**
58
     * @param itemId
59
     * @param propertyId
60
     */
61
    public Object getContainerProperty(Object itemId, Object propertyId) {
62
        if(prop.containsKey(propertyId) && prop.containsValue(itemId)){
63
            for (Map.Entry<String, String> entry : prop.entrySet()) {
64
                if(propertyId.toString().equalsIgnoreCase(entry.getKey())) {
65
                    return entry.getKey();
66
                }
67
            }
68
        }
69
        return null;
70
    }
71
}
(1-1/2)