Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.kie.workbench.common.services.datamodel.backend.server;
 
 import  javax.enterprise.context.ApplicationScoped;
 import  javax.inject.Inject;
 import  javax.inject.Named;
 
 import  org.drools.workbench.models.commons.backend.oracle.PackageDataModelOracleImpl;
 import  org.drools.workbench.models.commons.backend.oracle.ProjectDataModelOracleImpl;
 import  org.drools.workbench.models.datamodel.oracle.PackageDataModelOracle;
 import  org.drools.workbench.models.datamodel.oracle.ProjectDataModelOracle;
 import  org.guvnor.common.services.backend.exceptions.ExceptionUtilities;
 import  org.guvnor.common.services.project.model.Package;
 import  org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService;
 import  org.kie.workbench.common.services.shared.project.KieProject;
 import  org.kie.workbench.common.services.shared.project.KieProjectService;
 import  org.uberfire.backend.vfs.Path;
 import  org.uberfire.commons.validation.PortablePreconditions;
 
 @ApplicationScoped
 public class DataModelServiceImpl
         implements DataModelService {
 
     @Inject
     @Named("PackageDataModelOracleCache")
 
     @Inject
     @Named("ProjectDataModelOracleCache")
 
     @Inject
     private KieProjectService projectService;
 
     @Override
     public PackageDataModelOracle getDataModelfinal Path resourcePath ) {
         try {
             PortablePreconditions.checkNotNull( "resourcePath",
                                                 resourcePath );
             final KieProject project = resolveProjectresourcePath );
             final Package pkg = resolvePackageresourcePath );
 
             //Resource was not within a Project structure
             if ( project == null ) {
                 return new PackageDataModelOracleImpl();
             }
 
             //Retrieve (or build) oracle
             final PackageDataModelOracle oracle = .assertPackageDataModelOracleproject,
                                                                                               pkg );
             return oracle;
 
         } catch ( Exception e ) {
             throw ExceptionUtilities.handleException( e );
         }
     }
 
     @Override
     public ProjectDataModelOracle getProjectDataModelfinal Path resourcePath ) {
         try {
             PortablePreconditions.checkNotNull( "resourcePath",
                                                 resourcePath );
             final KieProject project = resolveProjectresourcePath );
 
             //Resource was not within a Project structure
             if ( project == null ) {
                 return new ProjectDataModelOracleImpl();
             }
 
             //Retrieve (or build) oracle
             final ProjectDataModelOracle oracle = .assertProjectDataModelOracleproject );
             return oracle;
 
         } catch ( Exception e ) {
             e.printStackTrace();
             throw ExceptionUtilities.handleException( e );
         }
     }
 
     private KieProject resolveProjectfinal Path resourcePath ) {
         return .resolveProject( resourcePath );
     }
    private Package resolvePackagefinal Path resourcePath ) {
        return .resolvePackage( resourcePath );
    }
New to GrepCode? Check out our FAQ X