com.bimface.sdk.service.TranslateService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bimface-java-sdk Show documentation
Show all versions of bimface-java-sdk Show documentation
Bimface provide the required call java sdk.
The newest version!
package com.bimface.sdk.service;
import com.bimface.api.bean.request.translate.FileTranslateRequest;
import com.bimface.api.bean.request.translate.TranslateQueryRequest;
import com.bimface.api.bean.request.v1.FileTranslateRequestV1;
import com.bimface.api.bean.response.FileTranslateBean;
import com.bimface.api.bean.response.FileTranslateDetailBean;
import com.bimface.api.bean.response.v1.FileTranslateResponseV1;
import com.bimface.api.enums.TranslatePolicy;
import com.bimface.bean.GeneralResponse;
import com.bimface.exception.BimfaceException;
import com.bimface.page.PagedList;
import com.bimface.sdk.client.ApiClient;
import com.bimface.sdk.config.Config;
import com.bimface.sdk.config.Endpoint;
import com.bimface.sdk.utils.AssertUtils;
import org.jetbrains.annotations.NotNull;
/**
* 文件转换
*
* @author bimface, 2016-06-01.
*/
public class TranslateService {
private ApiClient apiClient;
private AccessTokenService accessTokenService;
public TranslateService(Endpoint endpoint, AccessTokenService accessTokenService) {
this(endpoint, null, accessTokenService);
}
public TranslateService(Endpoint endpoint, Config config, AccessTokenService accessTokenService) {
this.apiClient = ApiClient.getApiClient(endpoint.getApiHost(), config);
this.accessTokenService = accessTokenService;
}
/**
* 发起文件转换
*
* @param request 文件转换请求
* @return {@link FileTranslateBean}
* @throws BimfaceException {@link BimfaceException}
*/
public FileTranslateBean translate(FileTranslateRequest request) throws BimfaceException {
return translate(request, accessTokenService.getAccessToken());
}
/**
* 发起文件转换
*
* @param request 文件转换请求
* @return {@link FileTranslateBean}
* @throws BimfaceException {@link BimfaceException}
*/
public FileTranslateBean translate(FileTranslateRequest request, String accessToken) throws BimfaceException {
check(request);
return apiClient.translate(request, accessToken);
}
/**
* 查看文件转换状态
*
* @param fileId 文件Id
* @return {@link FileTranslateBean}
* @throws BimfaceException {@link BimfaceException}
*/
public FileTranslateBean getTranslate(Long fileId) throws BimfaceException {
return getTranslate(fileId, accessTokenService.getAccessToken());
}
/**
* 查看文件转换状态
*
* @param fileId 文件Id
* @return {@link FileTranslateBean}
* @throws BimfaceException {@link BimfaceException}
*/
public FileTranslateBean getTranslate(Long fileId, String accessToken) throws BimfaceException {
return apiClient.getTranslation(fileId, accessToken);
}
/**
* 批量查看文件转换状态
*
* @param translateQueryRequest
* @return
* @throws BimfaceException
*/
public PagedList getTranslates(TranslateQueryRequest translateQueryRequest) throws BimfaceException {
return apiClient.getTranslations(translateQueryRequest, accessTokenService.getAccessToken());
}
/**
* 发起模型转换
*
* @param request FileTranslateRequest请求体
* @return
* @throws BimfaceException {@link BimfaceException}
*/
public FileTranslateBean translate2Bimtiles(FileTranslateRequest request) throws BimfaceException {
return apiClient.translate2Bimtiles(request, accessTokenService.getAccessToken());
}
/**
* 获取转换资源列表
*
* @param projectId 项目ID
* @param request FileTranslateRequestV1请求体
* @return
* @throws BimfaceException {@link BimfaceException}
*/
public com.bimface.page.es.PagedList fileTranslateList(Long projectId, FileTranslateRequestV1 request) throws BimfaceException {
return apiClient.fileTranslateList(projectId, request, accessTokenService.getAccessToken());
}
private void check(FileTranslateRequest request) {
AssertUtils.assertParameterNotNull(request, "TranslateRequest");
AssertUtils.assertParameterNotNull(request.getSource(), "source");
AssertUtils.assertParameterNotNull(request.getSource().getFileId(), "fileId");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy