Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/handlers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function getKeyFieldsForEntity(entity: cds.entity): string[] {
const keys = entity.keys;
const result: string[] = [];
for (const key in keys) {
if ((keys[key] as { virtual?: boolean }).virtual) continue;
result.push(key);
}
return result;
Expand Down
163 changes: 163 additions & 0 deletions tests/bookshop/srv/draft-annotation-service.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
using {sap.capire.bookshop as my} from '../db/shipment';

service DraftAnnotationService {

// ============================================
// Isolated draft entities for START annotation tests
// ============================================

// Start on CREATE without when condition (draft-enabled)
@bpm.process.start: {
id: 'draftStartOnCreateProcess',
on: 'CREATE',
}
@odata.draft.enabled
entity DraftStartOnCreate as
projection on my.Car {
ID,
model,
manufacturer,
mileage,
year
}

// Start on DELETE without when condition (draft-enabled)
@bpm.process.start: {
id: 'draftStartOnDeleteProcess',
on: 'DELETE',
}
@odata.draft.enabled
entity DraftStartOnDelete as
projection on my.Car {
ID,
model,
manufacturer,
mileage,
year
}

// ============================================
// Isolated draft entities for CANCEL annotation tests
// ============================================

// Cancel on CREATE with if condition (draft-enabled)
@bpm.process.cancel : {
on : 'CREATE',
cascade: true,
if : (mileage > 500),
}
@bpm.process.businessKey: (ID)
@odata.draft.enabled
entity DraftCancelOnCreateWhen as
projection on my.Car {
ID,
model,
manufacturer,
mileage,
year
}

// Cancel on UPDATE without when condition (draft-enabled)
@bpm.process.cancel : {
on : 'UPDATE',
cascade: false,
}
@bpm.process.businessKey: (ID)
@odata.draft.enabled
entity DraftCancelOnUpdate as
projection on my.Car {
ID,
model,
manufacturer,
mileage,
year
}

// Cancel on DELETE without when condition (draft-enabled)
@bpm.process.cancel : {
on : 'DELETE',
cascade: false,
}
@bpm.process.businessKey: (ID)
@odata.draft.enabled
entity DraftCancelOnDelete as
projection on my.Car {
ID,
model,
manufacturer,
mileage,
year
}

// ============================================
// Isolated draft entities for SUSPEND annotation tests
// ============================================

// Suspend on CREATE without when condition (draft-enabled)
@bpm.process.suspend : {
on : 'CREATE',
cascade: false,
}
@bpm.process.businessKey: (ID)
@odata.draft.enabled
entity DraftSuspendOnCreate as
projection on my.Car {
ID,
model,
manufacturer,
mileage,
year
}

// ============================================
// Isolated draft entities for RESUME annotation tests
// ============================================

// Resume on CREATE without when condition (draft-enabled)
@bpm.process.resume : {
on : 'CREATE',
cascade: false,
}
@bpm.process.businessKey: (ID)
@odata.draft.enabled
entity DraftResumeOnCreate as
projection on my.Car {
ID,
model,
manufacturer,
mileage,
year
}

// ============================================
// DRAFT LIFECYCLE COMBINATION SCENARIOS
// ============================================

// Full Lifecycle with draft: Start on CREATE, Suspend/Resume on UPDATE, Cancel on DELETE
@bpm.process.start : {
id: 'draftLifecycleProcess',
on: 'CREATE',
}
@bpm.process.suspend : {
on: 'UPDATE',
if: (mileage > 800),
}
@bpm.process.resume : {
on: 'UPDATE',
if: (mileage <= 800),
}
@bpm.process.cancel : {
on : 'DELETE',
cascade: true
}
@bpm.process.businessKey: (ID)
@odata.draft.enabled
entity DraftFullLifecycle {
key ID : UUID;
model : String(100);
manufacturer : String(100);
mileage : Integer;
year : Integer;
}

}
Loading
Loading