Search in sources :

Example 56 with Workspace

use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.

the class WorkspaceDao method getWorkspaceIfExists.

@ReadTransaction
public Optional<Workspace> getWorkspaceIfExists(UUID id) {
    if (id == null) {
        throw new MissingRequiredFieldException("Valid workspace id is required");
    }
    String sql = WORKSPACE_SELECT_SQL + " WHERE workspace_id = :id";
    MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id.toString());
    try {
        Workspace result = DataAccessUtils.requiredSingleResult(jdbcTemplate.query(sql, params, WORKSPACE_ROW_MAPPER));
        logger.info("Retrieved workspace record {}", result);
        return Optional.of(result);
    } catch (EmptyResultDataAccessException e) {
        return Optional.empty();
    }
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) MissingRequiredFieldException(bio.terra.common.exception.MissingRequiredFieldException) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) Workspace(bio.terra.workspace.service.workspace.model.Workspace) ReadTransaction(bio.terra.common.db.ReadTransaction)

Aggregations

Workspace (bio.terra.workspace.service.workspace.model.Workspace)56 Test (org.junit.jupiter.api.Test)32 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)23 UUID (java.util.UUID)13 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)9 BaseUnitTest (bio.terra.workspace.common.BaseUnitTest)8 FlightDebugInfo (bio.terra.stairway.FlightDebugInfo)6 HashMap (java.util.HashMap)6 FlightMap (bio.terra.stairway.FlightMap)5 StepStatus (bio.terra.stairway.StepStatus)5 ApiClonedWorkspace (bio.terra.workspace.generated.model.ApiClonedWorkspace)5 ApiCreatedWorkspace (bio.terra.workspace.generated.model.ApiCreatedWorkspace)5 SpendProfileId (bio.terra.workspace.service.spendprofile.SpendProfileId)5 DisabledIfEnvironmentVariable (org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)5 ResponseEntity (org.springframework.http.ResponseEntity)5 Traced (io.opencensus.contrib.spring.aop.Traced)4 FlightState (bio.terra.stairway.FlightState)3 ControlledBigQueryDatasetResource (bio.terra.workspace.service.resource.controlled.cloud.gcp.bqdataset.ControlledBigQueryDatasetResource)3 CreateWorkspaceStep (bio.terra.workspace.service.workspace.flight.CreateWorkspaceStep)3 GcpCloudContext (bio.terra.workspace.service.workspace.model.GcpCloudContext)3