All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.maximo.oslc.SavedQuery Maven / Gradle / Ivy

/*
* Licensed Materials - Property of IBM
*
* (C) COPYRIGHT IBM CORP. 2015 All Rights Reserved
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
 */

package com.ibm.maximo.oslc;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.xml.datatype.DatatypeConfigurationException;

public class SavedQuery {
	private String name = null;
	private Map map = new HashMap();
	
	public SavedQuery() {
	}
	
	public SavedQuery(String name,Map map){
		this.name=name;
		this.map=map;
	}
	

	public SavedQuery name(String name){
		this.name = name;
		return this;
	}
	public SavedQuery params(Map params){
		this.map=params;
		return this;
	}
	public SavedQuery addParam(String key, Object value){
		map.put(key, value);
		return this;
	}
	
	public String savedQueryClause(){
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append(this.name);
		Set> set = this.map.entrySet();
		for(Map.Entry entry : set)
		{
			try {
				strBuilder.append("&").append("sqp:");
				strBuilder.append(entry.getKey());
				String encodeValue = Util.urlEncode(Util.stringValue(entry.getValue()));
				strBuilder.append("=").append(encodeValue);
			} catch (UnsupportedEncodingException e){
				
			}catch(DatatypeConfigurationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return strBuilder.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy