All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.joinedworkz.common.javax.DaoCartridge.xtend Maven / Gradle / Ivy

There is a newer version: 1.3.46
Show newest version
package org.joinedworkz.common.javax

import java.util.Properties
import javax.inject.Inject
import javax.inject.Singleton
import org.joinedworkz.common.helper.CmnModelHelper
import org.joinedworkz.common.java.ClassGeneratorContext
import org.joinedworkz.common.javax.generator.DaoClassGenerator
import org.joinedworkz.common.javax.generator.DaoInterfaceGenerator
import org.joinedworkz.common.javax.generator.LiquibaseGenerator
import org.joinedworkz.core.facility.AbstractCartridge
import org.joinedworkz.core.facility.Outlet
import org.joinedworkz.core.facility.Outlets
import org.joinedworkz.core.model.CmnComplexType
import org.joinedworkz.core.model.CmnModel
import org.joinedworkz.core.model.CmnObject

@Singleton
class DaoCartridge extends AbstractCartridge {

	@Inject
	protected extension CmnModelHelper cmnModelHelper
	
	@Inject
	protected DaoInterfaceGenerator daoInterfaceGenerator;
	
	@Inject
	protected DaoClassGenerator daoClassGenerator;
	
	override apply(CmnObject cmnObj, Outlets outlets) {
        apply(cmnObj, outlets, null)
    }

	override void apply(CmnObject obj, Outlets outlets, Properties properties) {
		val generatedJavaSourceSlot = outlets.get("generatedJavaSource")
		val liquibaseConfiguration = outlets.get("liquibaseConfiguration")
		if (obj instanceof CmnModel) {
			new LiquibaseGenerator(obj, liquibaseConfiguration).generateConfiguration()
			for (modelElement : obj.modelElements) {
				modelElement.generateModelElement(generatedJavaSourceSlot, properties)
			}
		}
	}

	def void generateModelElement(CmnObject obj, Outlet outlet, Properties properties) {
		if (obj instanceof CmnComplexType) {
			if (!obj.abstract) {
				daoClassGenerator.generateClass(createGeneratorContext(obj, outlet, properties))
				daoInterfaceGenerator.generateClass(createGeneratorContext(obj, outlet, properties))
			}
		}
	}
	
	def  ClassGeneratorContext  createGeneratorContext(T classObject, Outlet outlet, Properties properties) {
		return new ClassGeneratorContext(classObject,outlet, properties)
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy