Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Introduction

This document describes the steps to add customized tokens for label printing. This guide is intended for developers or technical IT staff. 

Prerequisites

One should have done the setup the plugin as per steps given at how to write a plugin for OpenSpecimen?

Steps

To customize the Print token implementation one needs to follow the below steps:

  1. Write a class that extends AbstractLabelTmplToken and implements LabelTmplToken. The following example describes how to implement LabelTmplToken:

 

public class SpecimenCollectionContainerPrintToken extends AbstractLabelTmplToken implements LabelTmplToken {

	@Override
	public String getName() {
		return "specimen_collection_container";
	}

	@Override
	public String getReplacement(Object object) {
		Specimen specimen = (Specimen)object;
		while (specimen.getParentSpecimen() != null) {
			specimen = specimen.getParentSpecimen();
		}

		return specimen.getCollectionEvent().getContainer();
	}

}

 

     2. The next step will be to register this new token with the com.krishagni.catissueplus.core.common.domain.LabelTmplTokenRegistrar, to make OpenSpecimen aware of this new token. To register the new token, one needs to write a java class in the plugin like below:

 

public class PluginInitializer implements InitializingBean {
	
	private LabelTmplTokenRegistrar specimenPrintLabelTokensRegistrar;
	
	public void setSpecimenPrintLabelTokensRegistrar(LabelTmplTokenRegistrar specimenPrintLabelTokensRegistrar) {
		this.specimenPrintLabelTokensRegistrar = specimenPrintLabelTokensRegistrar;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		specimenPrintLabelTokensRegistrar.register(new SpecimenCollectionContainerPrintToken());
	}
}

 

      3. After adding this plugin initializer class you also need to define this bean in the spring context file located at PLUGIN_HOME/src/main/resources/pluginContext.xml. Following example describes how to define this bean:

<bean id="pluginInitializer" class="com.krishagni.openspecimen.plugin.init.PluginInitializer">
  <property name="specimenPrintLabelTokensRegistrar" ref="specimenPrintLabelTokensRegistrar"/>
</bean>

 

 

  • No labels