io.personium.client.EntityTypeManager.java Source code

Java tutorial

Introduction

Here is the source code for io.personium.client.EntityTypeManager.java

Source

/**
 * Personium
 * Copyright 2014 - 2017 FUJITSU LIMITED
 *
 * 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 io.personium.client;

import java.util.HashMap;

import org.json.simple.JSONObject;

///**
// * EntityType?CRUD????.
// */
/**
 * It creates a new object of EntityTypeManager. This class performs The CRUD operations for EntityType.
 */
public class EntityTypeManager extends ODataManager {

    // /**
    // * .
    // * @param as 
    // * @param col Dav
    // */
    /**
     * /** This is the parameterized constructor with two arguments and calling its parent constructor internally.
     * @param as Accessor
     * @param col DcCollection object
     */
    public EntityTypeManager(Accessor as, PersoniumCollection col) {
        super(as, col);
    }

    /**
     * Thi smethod generates and returns the URL for performing operations on EntityType.
     * @return URL value
     */
    @Override
    public String getUrl() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.collection.getPath());
        sb.append("/$metadata/EntityType");
        return sb.toString();
    }

    // /**
    // * EntityType?.
    // * @param obj EntityType
    // * @return EntityType
    // * @throws DaoException DAO
    // */
    /**
     * This method creates an EntityType from EntityType object.
     * @param obj EntityType object
     * @return EntityType object that is created
     * @throws DaoException Exception thrown
     */
    @SuppressWarnings("unchecked")
    public EntityType create(EntityType obj) throws DaoException {
        JSONObject body = new JSONObject();
        body.put("Name", obj.getName());
        JSONObject json = internalCreate(body);
        obj.initialize(this.accessor, json);
        return obj;
    }

    // /**
    // * EntityType?.
    // * @param body 
    // * @return ???Box
    // * @throws DaoException DAO
    // */
    /**
     * This method creates an EntityType from request body.
     * @param body Request Body
     * @return EntityType object that is created
     * @throws DaoException Exception thrown
     */
    public EntityType create(HashMap<String, Object> body) throws DaoException {
        JSONObject json = (JSONObject) internalCreate(body);
        return new EntityType(accessor, json);
    }

    // /**
    // * Box?.
    // * @param name ??box??
    // * @return ?????Box
    // * @throws DaoException DAO
    // */
    /**
     * This method retrieves a specified EntityType.
     * @param name EntityTypeName
     * @return EntityType object
     * @throws DaoException Exception thrown
     */
    public EntityType retrieve(String name) throws DaoException {
        JSONObject json = internalRetrieve(name);
        return new EntityType(accessor, json);
    }
}