1 /***
2 * Copyright (C) 2009 TM-Search Community.
3 *
4 * This file is part of TM-Search Services.
5 *
6 * Foobar is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Foobar is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package eu.europa.tmsearch.services.business;
21
22 import java.util.Date;
23
24 import org.apache.log4j.Logger;
25
26 import eu.europa.tmsearch.services.business.util.ST13Converter;
27 import eu.europa.tmsearch.services.dao.TradeMarkDAO;
28 import eu.europa.tmsearch.services.resources.exceptions.ResourceNotFoundException;
29 import eu.europa.tmsearch.services.schemas.trademark.data.TradeMarkType;
30
31 /***
32 * An implementation of TradeMark service business logic
33 *
34 *
35 * @see TradeMark
36 */
37 public class TradeMarkServiceImpl implements TradeMarkService {
38
39 private static Logger log = Logger.getLogger(TradeMarkServiceImpl.class);
40
41 /***
42 * A DAO accessing trade marks in the data store
43 */
44 private TradeMarkDAO tradeMarkDAO;
45
46 /***
47 * A from/to ST13 IDs/specific data store ID converter
48 */
49 private ST13Converter st13Converter;
50
51 /***
52 * Gets a TradeMark given a template TradeMark
53 *
54 * @param tradeMarkTemplate
55 * A TradeMark template used as
56 * @return A TradeMark containing the trade mark
57 * @throws ResourceNotFoundException
58 * If the trade mark ID does not exist
59 * @see TradeMark
60 */
61 public TradeMarkType getTradeMark(String tradeMarkID) throws ResourceNotFoundException {
62
63 if (log.isDebugEnabled()) {
64 log.debug("Retrieving Trademark With ID --> " + tradeMarkID);
65 }
66 TradeMarkType tradeMark = tradeMarkDAO.getTradeMarkByID(st13Converter.fromST13ID(tradeMarkID));
67 tradeMark.setApplicationNumber(st13Converter.toST13ID(tradeMark.getApplicationNumber()));
68
69 if (tradeMark.getMarkImageDetails() != null) {
70 tradeMark.getMarkImageDetails().getMarkImage().getMarkImageURI().setValue(
71 st13Converter.toST13ID(tradeMark.getMarkImageDetails().getMarkImage().getMarkImageURI()
72 .getValue()));
73 }
74
75 return tradeMark;
76 }
77
78 @Override
79 public Date getLastModified(String tradeMarkID) throws ResourceNotFoundException {
80 String applicationNumber = st13Converter.fromST13ID(tradeMarkID);
81 return tradeMarkDAO.getLastModified(applicationNumber);
82 }
83
84 @Override
85 public Date getExpires(String tradeMarkID) throws ResourceNotFoundException {
86 String applicationNumber = st13Converter.fromST13ID(tradeMarkID);
87 return tradeMarkDAO.getExpires(applicationNumber);
88 }
89
90 public void setTradeMarkDAO(TradeMarkDAO tradeMarkDAO) {
91 this.tradeMarkDAO = tradeMarkDAO;
92 }
93
94 public TradeMarkDAO getTradeMarkDAO() {
95 return tradeMarkDAO;
96 }
97
98 public ST13Converter getSt13Converter() {
99 return st13Converter;
100 }
101
102 public void setSt13Converter(ST13Converter st13Converter) {
103 this.st13Converter = st13Converter;
104 }
105
106 }