package be.cytomine.client.models;

/*
 * Copyright (c) 2009-2020. Authors: see NOTICE file.
 *
 * 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.
 */

import be.cytomine.client.CytomineException;

public class Software extends Model<Software> {
    public Software(){}
    public Software(String name, String resultType, String executeCommand, String softwareVersion){
        this.set("name", name);
        this.set("resultName", resultType);
        this.set("executeCommand", executeCommand);
        this.set("softwareVersion", softwareVersion);
    }

    public Software(String name, String resultType, String executeCommand, String softwareVersion, Long idSoftwareUserRepository, Long idDefaultProcessingServer){
        this.set("name", name);
        this.set("softwareUserRepository", idSoftwareUserRepository);
        this.set("defaultProcessingServer", idDefaultProcessingServer);
        this.set("resultName", resultType);
        this.set("executeCommand", executeCommand);
        this.set("softwareVersion", softwareVersion);
    }

    public Software(String name, String resultType, String executeCommand, String softwareVersion, Long idSoftwareUserRepository, Long idDefaultProcessingServer, String pullingCommand){
        this.set("name", name);
        this.set("softwareUserRepository", idSoftwareUserRepository);
        this.set("defaultProcessingServer", idDefaultProcessingServer);
        this.set("resultName", resultType);
        this.set("executeCommand", executeCommand);
        this.set("softwareVersion", softwareVersion);
        this.set("pullingCommand", pullingCommand);
    }

    public Software deprecate() throws CytomineException {
        this.set("deprecated", true);
        return this.update();
    }

}

@@ -684,25 +684,129 @@
 Cytomine
-Exception
+;%0Aimport be.cytomine.client.CytomineConnection;%0Aimport be.cytomine.client.CytomineException;%0A%0Aimport java.io.File
 ;%0A%0Apubli
@@ -2358,10 +2358,861 @@
 %0A    %7D%0A%0A
+    public void upload(File file) throws CytomineException %7B%0A        upload(Cytomine.getInstance().getDefaultCytomineConnection(), file);%0A    %7D%0A    public void upload(CytomineConnection connection, File file) throws CytomineException %7B%0A        String url = %22/api/%22+ getDomainName()+%22/%22+this.getId()+%22/upload%22;%0A        connection.uploadFile(url, file);%0A    %7D%0A%0A    public void download(String destPath) throws CytomineException %7B%0A        download(new File(destPath));%0A    %7D%0A    public void download(File dest) throws CytomineException %7B%0A        download(Cytomine.getInstance().getDefaultCytomineConnection(), dest);%0A    %7D%0A    public void download(CytomineConnection connection, File dest) throws CytomineException %7B%0A        String url = %22/api/%22+ getDomainName()+%22/%22+this.getId()+%22/download%22;%0A        connection.downloadFile(url, dest.getPath());%0A    %7D%0A%0A
 %7D%0A

add upload and download method for Software object