/** * Copyright © 2013 enioka. All rights reserved * Authors: Marc-Antoine GOUILLART (marc-antoine.gouillart@enioka.com) * Pierre COPPEE (pierre.coppee@enioka.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.enioka.jqm.model; import java.io.Serializable; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import com.enioka.jqm.jdbc.DatabaseException; import com.enioka.jqm.jdbc.DbConn; /** * <strong>Not part of any API - this an internal JQM class and may change without notice.</strong> <br> * Persistence class for storing the parameters of a {@link JobInstance}, and once archived of a {@link History}, Parameters are key/value * pairs that are passed to payloads at runtime. When a {@link JobDef} is instantiated, {@link RuntimeParameter}s are created from * {@link JobDefParameter}s as well as parameters specified inside the execution request and associated to the {@link JobInstance}. */ public class RuntimeParameter implements Serializable { private static final long serialVersionUID = -8894511645365690426L; private Integer id; private String key; private String value; private int ji; /** * The name of the parameter.<br> * Max length is 50. */ public String getKey() { return key; } /** * See {@link #getKey()} */ public void setKey(final String key) { this.key = key; } /** * Value of the parameter.<br> * Max length is 1000. */ public String getValue() { return value; } /** * See {@link #getValue()} */ public void setValue(final String value) { this.value = value; } /** * A technical ID without any meaning. Generated by the database. */ public Integer getId() { return id; } void setId(final Integer id) { this.id = id; } /** * ID of the History or JoBinstance to which this parameter belongs. */ public int getJi() { return ji; } /** * See {@link #getJi()} */ public void setJi(int ji) { this.ji = ji; } public static Map<String, String> select_map(DbConn cnx, String query_key, Object... args) { Map<String, String> res = new HashMap<String, String>(); try { ResultSet rs = cnx.runSelect(query_key, args); while (rs.next()) { res.put(rs.getString(3), rs.getString(4)); } } catch (SQLException e) { throw new DatabaseException(e); } return res; } public static void create(DbConn cnx, int jobInstanceId, String keyName, String value) { cnx.runUpdate("jiprm_insert", jobInstanceId, keyName, value); } }