4b7709632ea3b592a57ee765fb49887dcd826e74
[taxeditor.git] / eu.etaxonomy.taxeditor.cdmlib / src / main / java / eu / etaxonomy / taxeditor / session / DefaultNewEntityListener.java
1 /**
2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.session;
10
11 import org.apache.log4j.Logger;
12
13 import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController;
14 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
15 import eu.etaxonomy.cdm.model.NewEntityListener;
16 import eu.etaxonomy.cdm.model.common.CdmBase;
17
18 /**
19 * @author cmathew
20 * @date 30 Sep 2015
21 */
22 public class DefaultNewEntityListener implements NewEntityListener {
23
24 private static final Logger logger = Logger.getLogger(DefaultNewEntityListener.class);
25
26 @Override
27 public void onCreate(CdmBase cdmBase) {
28 logger.info("New Entity created : " + cdmBase);
29 if(CdmApplicationState.getCurrentAppConfig() instanceof CdmApplicationRemoteController){
30 ICdmEntitySession activeSession = ((CdmApplicationRemoteController)CdmApplicationState.getCurrentAppConfig()).getCdmEntitySessionManager().getActiveSession();
31 if(activeSession != null) {
32 activeSession.addNewCdmEntity(cdmBase);
33 }
34 }
35 }
36 }