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

com.innovenso.townplan.dsl.aspects.external.ExternalIdAspectConfigurer.groovy Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package com.innovenso.townplan.dsl.aspects.external


import com.innovenso.townplan.api.command.AddExternalIdAspectCommand
import com.innovenso.townplan.api.value.aspects.ExternalIdType
import com.innovenso.townplan.domain.TownPlanImpl
import com.innovenso.townplan.dsl.TownPlanConfigurer
import com.innovenso.townplan.dsl.aspects.AbstractAspectConfigurer
import com.innovenso.townplan.dsl.traits.HasRequiredKey
import lombok.NonNull
import org.apache.commons.lang3.tuple.Pair

class ExternalIdAspectConfigurer extends AbstractAspectConfigurer implements HasRequiredKey {
	private final List> ids = []

	ExternalIdAspectConfigurer(@NonNull TownPlanConfigurer townPlanConfigurer, @NonNull String conceptKey) {
		super(townPlanConfigurer, conceptKey)
	}

	void sparx(String value) {
		add(ExternalIdType.SPARX, value)
	}

	void confluence(String value) {
		add(ExternalIdType.CONFLUENCE, value)
	}

	private void add(ExternalIdType externalIdType, String value) {
		ids.add(Pair.of(externalIdType, value))
	}

	@Override
	String aspectType() {
		return "External ID"
	}

	@Override
	def apply(@NonNull TownPlanImpl townPlan) {
		ids.each {
			townPlan.execute(AddExternalIdAspectCommand.builder()
					.type(it.left)
					.value(it.right)
					.conceptKey(conceptKey)
					.build())
		}
	}

	@Override
	List getDefaultKeyComponents() {
		return [
			conceptKey,
			aspectType(),
			UUID.randomUUID().toString()
		]
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy