-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from ALNAUA/candidateReferenceRestTrigger
added CandidateReferenceRestTrigger support
- Loading branch information
Showing
5 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/com/client/core/base/model/helper/impl/CandidateReferenceTriggerHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.client.core.base.model.helper.impl; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateReference; | ||
import com.client.core.base.model.helper.AbstractTriggerHelper; | ||
import com.client.core.base.model.relatedentity.BullhornRelatedEntity; | ||
import com.client.core.base.model.relatedentity.CandidateReferenceRelatedEntity; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public abstract class CandidateReferenceTriggerHelper extends AbstractTriggerHelper<CandidateReference> { | ||
|
||
public CandidateReferenceTriggerHelper(Integer updatingUserID, Map<? extends BullhornRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(updatingUserID, CandidateReference.class, CandidateReferenceRelatedEntity.CANDIDATE_REFERENCE, relatedEntityFields); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...re/resttrigger/controller/candidatereference/CandidateReferenceRestTriggerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.client.core.resttrigger.controller.candidatereference; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateReference; | ||
import com.client.core.base.model.relatedentity.CandidateReferenceRelatedEntity; | ||
import com.client.core.base.workflow.node.TriggerValidator; | ||
import com.client.core.resttrigger.controller.AbstractRestTriggerController; | ||
import com.client.core.resttrigger.model.api.RestTriggerRequest; | ||
import com.client.core.resttrigger.model.api.RestTriggerResponse; | ||
import com.client.core.resttrigger.model.helper.impl.CandidateReferenceRestTriggerHelper; | ||
import com.client.core.resttrigger.workflow.traversing.CandidateReferenceRestTriggerTraverser; | ||
import org.apache.log4j.Logger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
@Controller | ||
@RequestMapping("/resttrigger/candidatereference/*") | ||
public class CandidateReferenceRestTriggerController extends AbstractRestTriggerController<CandidateReference, CandidateReferenceRestTriggerHelper, CandidateReferenceRestTriggerTraverser> { | ||
|
||
private final Logger log = Logger.getLogger(CandidateReferenceRestTriggerController.class); | ||
|
||
@Autowired | ||
public CandidateReferenceRestTriggerController(Optional<List<TriggerValidator<CandidateReference, CandidateReferenceRestTriggerHelper, CandidateReferenceRestTriggerTraverser>>> triggerValidators) { | ||
super(CandidateReference.class, triggerValidators, CandidateReferenceRelatedEntity.values()); | ||
} | ||
|
||
/** | ||
* Called when candidate is added | ||
* | ||
* @param body | ||
* | ||
* @return the json parsed form response message | ||
*/ | ||
@RequestMapping(value = { "add" }, method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) | ||
@ResponseBody | ||
public RestTriggerResponse addEntity(@RequestBody String body) { | ||
log.info("---------------------------- Starting Candidate Reference Add Validation Process From Rest Trigger ----------------------------------------"); | ||
|
||
Map<String, Object> valuesChanges = (Map<String, Object>) convertToMap(body).get("data"); | ||
|
||
RestTriggerRequest<CandidateReference> restTriggerRequest = convertToObject(body); | ||
|
||
Integer entityID = restTriggerRequest.getMeta().getEntityId(); | ||
Integer updatingUserID = restTriggerRequest.getMeta().getUserId(); | ||
|
||
CandidateReferenceRestTriggerTraverser traverser = new CandidateReferenceRestTriggerTraverser(entityID, valuesChanges, updatingUserID, false, getRelatedEntityFields()); | ||
|
||
return handleRequest(traverser, valuesChanges); | ||
} | ||
|
||
/** | ||
* Called when candidate is edited | ||
* | ||
* @param body | ||
* | ||
* @return the json parsed form response message | ||
*/ | ||
@RequestMapping(value = { "edit" }, method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) | ||
@ResponseBody | ||
public RestTriggerResponse editEntity(@RequestBody String body) { | ||
log.info("---------------------------- Starting Candidate Reference Edit Validation Process From Rest Trigger ----------------------------------------"); | ||
|
||
Map<String, Object> valuesChanges = (Map<String, Object>) convertToMap(body).get("data"); | ||
|
||
RestTriggerRequest<CandidateReference> restTriggerRequest = convertToObject(body); | ||
|
||
Integer entityID = restTriggerRequest.getMeta().getEntityId(); | ||
Integer updatingUserID = restTriggerRequest.getMeta().getUserId(); | ||
|
||
CandidateReferenceRestTriggerTraverser traverser = new CandidateReferenceRestTriggerTraverser(entityID, valuesChanges, updatingUserID, true, getRelatedEntityFields()); | ||
|
||
return handleRequest(traverser, valuesChanges); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...va/com/client/core/resttrigger/model/helper/impl/CandidateReferenceRestTriggerHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.client.core.resttrigger.model.helper.impl; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateReference; | ||
import com.client.core.base.model.helper.impl.CandidateReferenceTriggerHelper; | ||
import com.client.core.base.model.relatedentity.BullhornRelatedEntity; | ||
import com.client.core.base.model.relatedentity.CandidateReferenceRelatedEntity; | ||
import com.client.core.base.util.TriggerUtil; | ||
import com.client.core.resttrigger.model.helper.RestTriggerHelper; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class CandidateReferenceRestTriggerHelper extends CandidateReferenceTriggerHelper implements RestTriggerHelper<CandidateReference> { | ||
|
||
private final Integer entityID; | ||
private final Map<String, Object> valuesChanged; | ||
|
||
public CandidateReferenceRestTriggerHelper(Integer entityID, Map<String, Object> valuesChanged, Integer updatingUserID, | ||
Map<? extends BullhornRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(updatingUserID, relatedEntityFields); | ||
this.entityID = entityID; | ||
this.valuesChanged = valuesChanged; | ||
} | ||
|
||
@Override | ||
public Set<String> getPopulatedFields() { | ||
return valuesChanged.keySet(); | ||
} | ||
|
||
@Override | ||
public Integer getEntityID() { | ||
return entityID; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getValuesChanged() { | ||
return valuesChanged; | ||
} | ||
|
||
@Override | ||
protected CandidateReference instantiateNewEntity() { | ||
return TriggerUtil.populateEntity(entityID, CandidateReference.class, valuesChanged, CandidateReference::new, getFields(CandidateReferenceRelatedEntity.CANDIDATE_REFERENCE)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...om/client/core/resttrigger/workflow/node/impl/CandidateReferenceRestTriggerValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.client.core.resttrigger.workflow.node.impl; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateReference; | ||
import com.client.core.base.model.relatedentity.CandidateReferenceRelatedEntity; | ||
import com.client.core.resttrigger.model.helper.impl.CandidateReferenceRestTriggerHelper; | ||
import com.client.core.resttrigger.workflow.traversing.CandidateReferenceRestTriggerTraverser; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public abstract class CandidateReferenceRestTriggerValidator extends AbstractRestTriggerValidator<CandidateReference, CandidateReferenceRestTriggerHelper, CandidateReferenceRestTriggerTraverser> { | ||
|
||
public CandidateReferenceRestTriggerValidator(Integer order, Map<CandidateReferenceRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(order, relatedEntityFields); | ||
} | ||
|
||
public CandidateReferenceRestTriggerValidator(Map<CandidateReferenceRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(relatedEntityFields); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...m/client/core/resttrigger/workflow/traversing/CandidateReferenceRestTriggerTraverser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.client.core.resttrigger.workflow.traversing; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateReference; | ||
import com.client.core.base.model.relatedentity.BullhornRelatedEntity; | ||
import com.client.core.base.workflow.traversing.AbstractTriggerTraverser; | ||
import com.client.core.resttrigger.model.helper.impl.CandidateReferenceRestTriggerHelper; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class CandidateReferenceRestTriggerTraverser extends AbstractTriggerTraverser<CandidateReference, CandidateReferenceRestTriggerHelper> { | ||
|
||
public CandidateReferenceRestTriggerTraverser(Integer entityID, Map<String, Object> valuesChanged, Integer updatingUserID, boolean edit, | ||
Map<? extends BullhornRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(new CandidateReferenceRestTriggerHelper(entityID, valuesChanged, updatingUserID, relatedEntityFields), edit); | ||
} | ||
|
||
} |