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

org.labkey.remoteapi.assay.ExpObject Maven / Gradle / Ivy

Go to download

The client-side library for Java developers is a separate JAR from the LabKey Server code base. It can be used by any Java program, including another Java web application.

There is a newer version: 6.2.0
Show newest version
/*
 * Copyright (c) 2010-2017 LabKey Corporation
 *
 * 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 org.labkey.remoteapi.assay;

import org.json.JSONObject;
import org.labkey.remoteapi.ResponseObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Base class for experiment objects, including Run, Data, Batch, etc
 */
public abstract class ExpObject extends ResponseObject
{
    private Number _id;
    private String _name;
    private Map _properties = new HashMap<>();

    protected ExpObject()
    {
    }

    protected ExpObject(JSONObject json)
    {
        super(json.toMap());
        _id = json.optNumber("id");
        _name = json.optString("name", null);
        if (json.has("properties"))
        {
            _properties = json.optJSONObject("properties").toMap();
        }
    }

    public JSONObject toJSONObject()
    {
        JSONObject result = new JSONObject();
        result.put("id", _id);
        result.put("name", _name);
        result.put("properties", _properties);
        return result;
    }

    /** @return the auto-generated rowId for this object */
    public Integer getId()
    {
        return _id == null ? null : _id.intValue();
    }

    /** @param id the auto-generated rowId for this object */
    public void setId(int id)
    {
        _id = id;
    }

    /** @return the name assigned to this object */
    public String getName()
    {
        return _name;
    }

    /** @param name the name assigned to this object */
    public void setName(String name)
    {
        _name = name;
    }

    /** @return the customizable properties attached to this object (Run Properties, Batch Properties, etc) */
    public Map getProperties()
    {
        return _properties;
    }

    /** @param properties the customizable properties attached to this object (Run Properties, Batch Properties, etc) */
    public void setProperties(Map properties)
    {
        _properties = properties;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy