Skip to content

Commit

Permalink
feat(CostSurface): Small tweaks after rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
KevSanchez committed Sep 29, 2023
1 parent 993f914 commit 085c2c9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions api/apps/api/src/modules/scenarios/scenario.api.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TimeUserEntityMetadata } from '../../types/time-user-entity-metadata';
import { BaseServiceResource } from '../../types/resource.interface';
import { JsonApiAsyncJobMeta } from '@marxan-api/dto/async-job.dto';
import { ScenarioBlm } from '@marxan-api/modules/blm/values/repositories/scenario-blm/scenario-blm.api.entity';
import { CostSurface } from '@marxan-api/modules/cost-surface/cost-surface.api.entity';

export const scenarioResource: BaseServiceResource = {
className: 'Scenario',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ export async function GivenScenarioExists(
organizationId: string,
scenarioData: Record<string, any> = {},
projectData: Record<string, any> = {},
costSurfaceId = v4(),
) {
const costSurfaceId = v4();
await GivenProjectExists(
em,
projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const getFixtures = async () => {

const projectId = v4();
const scenarioId = v4();
const costSurfaceId = v4();
const organizationId = v4();
const sut = sandbox.get(ScenarioMetadataPieceExporter);
const apiEntityManager: EntityManager = sandbox.get(
Expand All @@ -105,6 +106,7 @@ const getFixtures = async () => {
ranAtLeastOnce: false,
solutionsAreLocked,
type: 'marxan',
cost_surface_id: costSurfaceId,
});

return {
Expand Down Expand Up @@ -140,6 +142,8 @@ const getFixtures = async () => {
metadata: { marxanInputParameterFile: { meta: '1' } },
solutions_are_locked: solutionsAreLocked,
},
{},
costSurfaceId,
);
},
GivenScenarioBlmRangeExist: async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const getFixtures = async () => {
const organizationId = v4();
const oldScenarioId = v4();
const userId = v4();
const costSurfaceId = v4();

const sut = sandbox.get(ScenarioMetadataPieceImporter);
const fileRepository = sandbox.get(CloningFilesRepository);
Expand All @@ -175,6 +176,7 @@ const getFixtures = async () => {
solutionsAreLocked,
projectScenarioId: 1,
type: 'marxan',
cost_surface_id: costSurfaceId,
});

return {
Expand All @@ -197,6 +199,9 @@ const getFixtures = async () => {
scenarioId,
projectId,
organizationId,
{},
{},
costSurfaceId,
);
},
GivenJobInput: (
Expand Down
21 changes: 11 additions & 10 deletions api/libs/cloning/src/infrastructure/clone-piece-data/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isDefined } from '../../../../utils/src';
import { SlugService } from '../../../../utils/src/slug.service';
import { ComponentLocation, ResourceKind } from '../../domain';
import { ResourceKind } from '../../domain';
import { ClonePiece } from '../../domain/clone-piece';
import { exportConfigRelativePath } from './export-config';
import { marxanExecutionMetadataRelativePath } from './marxan-execution-metadata';
Expand Down Expand Up @@ -55,22 +55,23 @@ export const clonePieceImportOrder: Record<ClonePiece, number> = {
//
[ClonePiece.ProjectMetadata]: 0,
//
[ClonePiece.ScenarioMetadata]: 1,
[ClonePiece.PlanningAreaGAdm]: 1,
[ClonePiece.PlanningAreaCustom]: 1,
[ClonePiece.PlanningUnitsGrid]: 1,
[ClonePiece.ProjectCustomProtectedAreas]: 1,
//
[ClonePiece.ProjectCustomFeatures]: 2,
[ClonePiece.ScenarioProtectedAreas]: 2,
[ClonePiece.ScenarioPlanningUnitsData]: 2,
[ClonePiece.ScenarioMetadata]: 2,
//
[ClonePiece.ProjectPuvsprCalculations]: 3,
[ClonePiece.ScenarioFeaturesData]: 3,
[ClonePiece.ProjectCustomFeatures]: 3,
[ClonePiece.ScenarioProtectedAreas]: 3,
[ClonePiece.ScenarioPlanningUnitsData]: 3,
//
[ClonePiece.ScenarioRunResults]: 4,
[ClonePiece.MarxanExecutionMetadata]: 4,
[ClonePiece.FeaturesSpecification]: 4,
[ClonePiece.ProjectPuvsprCalculations]: 4,
[ClonePiece.ScenarioFeaturesData]: 4,
//
[ClonePiece.ScenarioRunResults]: 5,
[ClonePiece.MarxanExecutionMetadata]: 5,
[ClonePiece.FeaturesSpecification]: 5,
};

export class ClonePieceRelativePathResolver {
Expand Down

0 comments on commit 085c2c9

Please sign in to comment.