Skip to main content
summaryrefslogtreecommitdiffstats
blob: 30576b63d65df5a75250bf67f789623744e31aad (plain) (blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************************
 * Copyright (c) 2011 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ote.core.log.record;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.eclipse.osee.framework.jdk.core.type.IPropertyStore;

public class PropertyStoreRecord extends TestRecord {

	private static final long serialVersionUID = -6515147544821433102L;
	private IPropertyStore store;

	public PropertyStoreRecord(IPropertyStore store) {
		super(null, Level.INFO, "PropertyStoreRecord", false);
		this.store = store;
	}

	@Override
	public void toXml(XMLStreamWriter writer) throws XMLStreamException {
		writer.writeStartElement("PropertyStore");
		if(store != null){
			for(String key:store.keySet()){
				String message = store.get(key);
				writer.writeStartElement("Property");
				writer.writeAttribute("key", key);
				writer.writeCharacters(message);
				writer.writeEndElement();
			}
		}
		writer.writeEndElement();
	}
	
	@JsonProperty
	public Map<String, String> getProperties() {
		Map<String, String> result = new HashMap<>();
		if (store != null && !store.isEmpty()) {
			for (String key : store.keySet()) {
				if (nonEmptyString(store.get(key)) != null) {
					result.put(key, store.get(key));
				}
			}
			return result;
		} else {
			return null;
		}
	}
	
	@Override
   @JsonIgnore
	public String getMessage() {
		return super.getMessage();
	}
}

Back to the top