001/** 002 * Copyright 2014 The Sculptor Project Team, including the original 003 * author or authors. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.sculptor.generator.cartridge.mongodb; 018 019import com.google.inject.Inject; 020import org.eclipse.xtext.xbase.lib.Extension; 021import org.sculptor.generator.cartridge.mongodb.MongoDbProperties; 022import org.sculptor.generator.cartridge.mongodb.MongoDbServiceTestTmpl; 023import org.sculptor.generator.chain.ChainOverride; 024import org.sculptor.generator.ext.Properties; 025import org.sculptor.generator.template.service.ServiceTmpl; 026import sculptormetamodel.Service; 027 028@ChainOverride 029@SuppressWarnings("all") 030public class ServiceTmplExtension extends ServiceTmpl { 031 @Inject 032 private MongoDbServiceTestTmpl mongoDbServiceTestTmpl; 033 034 @Inject 035 @Extension 036 private MongoDbProperties mongoDbProperties; 037 038 @Inject 039 @Extension 040 private Properties properties; 041 042 @Override 043 public String service(final Service it) { 044 ServiceTmpl headObj = getMethodsDispatchHead()[org.sculptor.generator.template.service.ServiceTmplMethodIndexes.SERVICE_SERVICE]; 045 return headObj._chained_service(it); 046 } 047 048 public ServiceTmplExtension(final ServiceTmpl next, final ServiceTmpl[] methodsDispatchNext) { 049 super(next); 050 } 051 052 public String _chained_service(final Service it) { 053 String _xblockexpression = null; 054 { 055 boolean _and = false; 056 boolean _isTestToBeGenerated = this.properties.isTestToBeGenerated(); 057 if (!_isTestToBeGenerated) { 058 _and = false; 059 } else { 060 boolean _mongoDb = this.mongoDbProperties.mongoDb(); 061 _and = _mongoDb; 062 } 063 if (_and) { 064 this.mongoDbServiceTestTmpl.serviceJUnitSubclassMongoDb(it); 065 } 066 ServiceTmpl _next = this.getNext(); 067 _xblockexpression = _next.service(it); 068 } 069 return _xblockexpression; 070 } 071 072 public ServiceTmpl[] _getOverridesDispatchArray() { 073 org.sculptor.generator.template.service.ServiceTmpl[] result = new org.sculptor.generator.template.service.ServiceTmpl[org.sculptor.generator.template.service.ServiceTmplMethodIndexes.NUM_METHODS]; 074 result[org.sculptor.generator.template.service.ServiceTmplMethodIndexes.SERVICE_SERVICE] = this; 075 return result; 076 } 077}