Add find method which can be filtered to update editor session
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / TestServiceImpl.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.api.service;
11
12 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.stereotype.Service;
14 import org.springframework.transaction.annotation.Transactional;
15
16 import eu.etaxonomy.cdm.api.service.UpdateResult.Status;
17 import eu.etaxonomy.cdm.api.service.dto.CdmEntityIdentifier;
18 import eu.etaxonomy.cdm.model.taxon.Taxon;
19 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20
21 /**
22 * @author cmathew
23 * @date 26 Jun 2015
24 *
25 */
26 @Service
27 public class TestServiceImpl implements ITestService {
28
29 @Autowired
30 ITaxonNodeService taxonNodeService;
31
32 /* (non-Javadoc)
33 * @see eu.etaxonomy.cdm.api.service.ITestService#wait(int)
34 */
35 @Override
36 public void waitFor(long timeToWaitInMs) throws InterruptedException {
37 Thread.sleep(timeToWaitInMs);
38 }
39
40 /* (non-Javadoc)
41 * @see eu.etaxonomy.cdm.api.service.ITestService#returnResult(eu.etaxonomy.cdm.api.service.UpdateResult)
42 */
43 @Override
44 public UpdateResult returnResult(UpdateResult result) {
45 return result;
46 }
47
48 /* (non-Javadoc)
49 * @see eu.etaxonomy.cdm.api.service.ITestService#throwException(java.lang.Exception)
50 */
51 @Override
52 public UpdateResult throwException(Exception ex) {
53 throw new RuntimeException(ex);
54 }
55
56 /* (non-Javadoc)
57 * @see eu.etaxonomy.cdm.api.service.ITestService#addChild(eu.etaxonomy.cdm.api.service.dto.CdmEntityIdentifier)
58 */
59 @Override
60 @Transactional(readOnly = false)
61 public UpdateResult addChild(CdmEntityIdentifier taxonNodeCei) {
62 TaxonNode taxonNode = taxonNodeService.find(taxonNodeCei.getId());
63 taxonNode.addChildTaxon(Taxon.NewInstance(null, null), null, null);
64 UpdateResult result = new UpdateResult();
65 result.addUpdatedCdmId(taxonNodeCei);
66 result.setStatus(Status.OK);
67 return result;
68 }
69
70 }