Class CardManager
- java.lang.Object
-
- ch.colabproject.colab.api.controller.card.CardManager
-
public class CardManager extends Object
Card, card type and card content specific logic- Author:
- sandra
-
-
Constructor Summary
Constructors Constructor Description CardManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Card
assertAndGetCard(Long cardId)
Retrieve the card.void
changeCardPosition(Long cardId, GridPosition position)
Change the position of the card (stay in the same parent, just change position within grid)boolean
checkIntegrity(Card card)
Check the integrity of the cardvoid
createCardType(Long cardId)
Create a card type for a card which has noneCard
createNewCard(Long parentId, Long cardTypeId)
Complete and persist a new card into the given card content with the given card type.void
deleteCard(Long cardId)
Delete the given cardList<ActivityFlowLink>
getActivityFlowLinkAsNext(Long cardId)
Get all activity flow links of which the given card is the next oneList<ActivityFlowLink>
getActivityFlowLinkAsPrevious(Long cardId)
Get all activity flow links of which the given card is the previous oneList<Card>
getAliveSubCards(CardContent parent)
Set<CardContent>
getAllCardContents(Card rootCard)
Get all cardContentsSet<Card>
getAllCards(Card rootCard)
Get a card and all cards within in one set.List<Assignment>
getAssignments(Long cardId)
Retrieve the list of assignments for the given cardList<CardContent>
getContentVariants(Long cardId)
Get all variants content for the given cardList<StickyNoteLink>
getStickyNoteLinkAsDest(Long cardId)
Get all sticky note links of which the given card is the destinationList<StickyNoteLink>
getStickyNoteLinkAsSrcCard(Long cardId)
Get all sticky note links of which the given card is the sourceCard
initNewRootCard()
Initialize a new root card.void
markCardAsToDeleteForever(Long cardId)
Set the deletion status to TO_DELETE.void
moveCard(Long cardId, Long newParentId)
Move a card to a new parentvoid
moveCardAbove(Long cardId)
Move a card to its grandparent card content.void
putCardInBin(Long cardId)
Put the given card in the bin.void
removeCardType(Long cardId)
Remove the card type of the card.void
restoreCardFromBin(Long cardId)
Restore from the bin.
-
-
-
Method Detail
-
assertAndGetCard
public Card assertAndGetCard(Long cardId)
Retrieve the card. If not found, throw aHttpErrorMessage
.- Parameters:
cardId
- the id of the card- Returns:
- the card if found
- Throws:
ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage
- if the card was not found
-
getAllCards
public Set<Card> getAllCards(Card rootCard)
Get a card and all cards within in one set.- Parameters:
rootCard
- the first card- Returns:
- the rootCard + all cards within
-
getAllCardContents
public Set<CardContent> getAllCardContents(Card rootCard)
Get all cardContents- Parameters:
rootCard
- the first card- Returns:
- all cardContent in the card hierarchy
-
getAliveSubCards
public List<Card> getAliveSubCards(CardContent parent)
- Parameters:
parent
- the card content parent- Returns:
- All not-deleted cards under the given card content.
-
createNewCard
public Card createNewCard(Long parentId, Long cardTypeId)
Complete and persist a new card into the given card content with the given card type.Also create its default resource references.
- Parameters:
parentId
- the id of the parent of the new cardcardTypeId
- the id of the card type of the new card. Can be null- Returns:
- a new, initialized and persisted card
-
initNewRootCard
public Card initNewRootCard()
Initialize a new root card. This card contains every other cards of a project.No persistence stuff in there
- Returns:
- a new card dedicated to be the root card of a project
-
putCardInBin
public void putCardInBin(Long cardId)
Put the given card in the bin. (= set DeletionStatus to BIN + set erasure tracking data)- Parameters:
cardId
- the id of the card
-
restoreCardFromBin
public void restoreCardFromBin(Long cardId)
Restore from the bin. The object won't contain any deletion or erasure data anymore.It means that the card is back at its place (as much as possible).
If the parent card is deleted, the card is moved at the root of the project.
- Parameters:
cardId
- the id of the card
-
markCardAsToDeleteForever
public void markCardAsToDeleteForever(Long cardId)
Set the deletion status to TO_DELETE.It means that the card is only visible in the bin panel.
- Parameters:
cardId
- the id of the card
-
deleteCard
public void deleteCard(Long cardId)
Delete the given card- Parameters:
cardId
- the id of the card to delete
-
changeCardPosition
public void changeCardPosition(Long cardId, GridPosition position)
Change the position of the card (stay in the same parent, just change position within grid)Recompute the position of all the sister cards
- Parameters:
cardId
- the id of the cardposition
- the new position to set
-
moveCard
public void moveCard(Long cardId, Long newParentId)
Move a card to a new parent- Parameters:
cardId
- id of the card to movenewParentId
- id of the new parent- Throws:
ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage
- if card or parent does not exist or if parent is a child of the card
-
moveCardAbove
public void moveCardAbove(Long cardId)
Move a card to its grandparent card content. (aka move a level up)- Parameters:
cardId
- the id of the card to move- Throws:
ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage
- if card or parent does not exist
-
getContentVariants
public List<CardContent> getContentVariants(Long cardId)
Get all variants content for the given card- Parameters:
cardId
- the id of the card- Returns:
- all card contents of the card
-
getStickyNoteLinkAsDest
public List<StickyNoteLink> getStickyNoteLinkAsDest(Long cardId)
Get all sticky note links of which the given card is the destination- Parameters:
cardId
- the id of the card- Returns:
- all sticky note linked from the card
-
getStickyNoteLinkAsSrcCard
public List<StickyNoteLink> getStickyNoteLinkAsSrcCard(Long cardId)
Get all sticky note links of which the given card is the source- Parameters:
cardId
- the id of the card- Returns:
- all sticky note linked to the card
-
getActivityFlowLinkAsPrevious
public List<ActivityFlowLink> getActivityFlowLinkAsPrevious(Long cardId)
Get all activity flow links of which the given card is the previous one- Parameters:
cardId
- the id of the card- Returns:
- all activity flow linked to the card
-
getActivityFlowLinkAsNext
public List<ActivityFlowLink> getActivityFlowLinkAsNext(Long cardId)
Get all activity flow links of which the given card is the next one- Parameters:
cardId
- the id of the card- Returns:
- all activity flow linked from the card
-
getAssignments
public List<Assignment> getAssignments(Long cardId)
Retrieve the list of assignments for the given card- Parameters:
cardId
- id of the card- Returns:
- list of assignments
-
checkIntegrity
public boolean checkIntegrity(Card card)
Check the integrity of the card- Parameters:
card
- the card to check- Returns:
- true iff the card is complete and safe
-
createCardType
public void createCardType(Long cardId)
Create a card type for a card which has none- Parameters:
cardId
- the card id
-
removeCardType
public void removeCardType(Long cardId)
Remove the card type of the card.For now, it handles only card types that have no resource
- Parameters:
cardId
- the card id
-
-