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

net.anotheria.anosite.gen.assitedata.action.EditMediaLinkAction Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** EditMediaLinkAction.java                                                 ***
 *** generated by AnoSiteGenerator (ASG), Version: 2.6.3                      ***
 *** Copyright (C) 2005 - 2010 Anotheria.net, www.anotheria.net               ***
 *** All Rights Reserved.                                                     ***
 ********************************************************************************
 *** Don't edit this code, if you aren't sure                                 ***
 *** that you do exactly know what you are doing!                             ***
 *** It's better to invest time in the generator, as into the generated code. ***
 ********************************************************************************
 */

package net.anotheria.anosite.gen.assitedata.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionForward;
import net.anotheria.maf.action.ActionMapping;
import net.anotheria.maf.bean.FormBean;
import java.util.List;
import java.util.ArrayList;
import net.anotheria.anosite.gen.assitedata.bean.EditMediaLinkFB;
import net.anotheria.anosite.gen.assitedata.data.MediaLink;
import net.anotheria.asg.util.helper.cmsview.CMSViewHelperUtil;
import net.anotheria.asg.util.helper.cmsview.CMSViewHelperRegistry;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.anosite.gen.shared.data.MediaDescEnum;
import net.anotheria.anosite.gen.shared.data.LinkTypesEnum;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.anosite.gen.asresourcedata.data.FileLink;
import net.anotheria.asg.exception.ConstantNotFoundException;


public class EditMediaLinkAction extends ShowMediaLinksAction{

// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEditAction

	// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEditActionMethod

	public ActionForward anoDocExecute(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		String id = getStringParameter(req, PARAM_ID);
		EditMediaLinkFB form = new EditMediaLinkFB() ;
		MediaLink medialink = getASSiteDataService().getMediaLink(id);
		checkMediaLinks(medialink, req);
		if(medialink instanceof LockableObject && !((LockableObject)medialink).isLocked() && isAutoLockingEnabled())
			lockMediaLinks(medialink, req);
		form.setId(medialink.getId());
		form.setName(medialink.getName());
		form.setFile(medialink.getFile());
		form.setHref(medialink.getHref());
		form.setType(medialink.getType());
		form.setMedia(medialink.getMedia());
		form.setRel(medialink.getRel());
		form.setRev(medialink.getRev());
		form.setHreflang(medialink.getHreflang());
		form.setCharset(medialink.getCharset());
		form.setBrowserFiltering(medialink.getBrowserFiltering());
		form.setOnload(medialink.getOnload());
		// guards is a table, storing size only
		form.setGuards(medialink.getGuardsSize());
		form.setLocked(((LockableObject)medialink).isLocked());
		form.setLockerId(((LockableObject)medialink).getLockerId());
		form.setLockingTime(net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)medialink).getLockingTime()) + " automatic unlock expected AT : " + net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)medialink).getLockingTime() + getLockingTimeout()));


		//link file to ASResourceData.FileLink
		List filelinks = getASResourceDataService().getFileLinks();
		List filelinksValues = new ArrayList(filelinks.size()+1);
		filelinksValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.asresourcedata.data.FileLink filelinkTemp : filelinks){
			LabelValueBean bean = new LabelValueBean(filelinkTemp.getId(), filelinkTemp.getName() + " [" + filelinkTemp.getId() + "]" );
			filelinksValues.add(bean);
		}
		form.setFileCollection(filelinksValues);
		try{
			form.setFileCurrentValue(getASResourceDataService().getFileLink(medialink.getFile()).getName());
		}catch(Exception e){
			form.setFileCurrentValue("none");
			form.setFileIdOfCurrentValue("none");
		}
		// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEnumerationPropertyHandling


		//enumeration MediaDesc
		MediaDescEnum[] MediaDesc_values = MediaDescEnum.values();
		List MediaDesc_valuesListValues = new ArrayList(MediaDesc_values.length);
		for (MediaDescEnum element : MediaDesc_values) {
			LabelValueBean bean = new LabelValueBean(""+element.getValue(), element.name());
			MediaDesc_valuesListValues.add(bean);
		}
		form.setMediaCollection(MediaDesc_valuesListValues);
		try {
			form.setMediaCurrentValue(MediaDescEnum.getConstantByValue(medialink.getMedia()).name());
		} catch (net.anotheria.asg.exception.ConstantNotFoundException e) {
		} //try
		// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEnumerationPropertyHandling


		//enumeration LinkTypes
		LinkTypesEnum[] LinkTypes_values = LinkTypesEnum.values();
		List LinkTypes_valuesListValues = new ArrayList(LinkTypes_values.length);
		for (LinkTypesEnum element : LinkTypes_values) {
			LabelValueBean bean = new LabelValueBean(""+element.getValue(), element.name());
			LinkTypes_valuesListValues.add(bean);
		}
		form.setRelCollection(LinkTypes_valuesListValues);
		try {
			form.setRelCurrentValue(LinkTypesEnum.getConstantByValue(medialink.getRel()).name());
		} catch (net.anotheria.asg.exception.ConstantNotFoundException e) {
		} //try
		// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEnumerationPropertyHandling


		//enumeration LinkTypes already prepared.
		form.setRevCollection(LinkTypes_valuesListValues);
		try {
			form.setRevCurrentValue(LinkTypesEnum.getConstantByValue(medialink.getRev()).name());
		} catch (net.anotheria.asg.exception.ConstantNotFoundException e) {
		} //try
		addBeanToRequest(req, "objectId" , medialink.getId());
		addBeanToRequest(req, "EditASSiteDataMediaLinkForm" , form);
		addBeanToRequest(req, "objectInfoString" , medialink.getObjectInfo().toString());
		addBeanToRequest(req, "apply.label.prefix", "Apply");
		addBeanToRequest(req, "save.label.prefix", "Save");

		addFieldExplanations(req, medialink);

		return mapping.findForward("success");
	}

	private void addFieldExplanations(HttpServletRequest req, MediaLink medialink) {
		if (!CMSViewHelperRegistry.getCMSViewHelpers("ASSiteData.MediaLink").isEmpty()) {
			String fieldDescription = null;
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "name");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.name", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "href");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.href", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "type");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.type", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "media");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.media", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "rel");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.rel", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "rev");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.rev", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "charset");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.charset", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "hreflang");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.hreflang", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "browserFiltering");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.browserFiltering", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "onload");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.onload", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.MediaLink", medialink, "guards");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.guards", fieldDescription);
		} //
	} //addFieldExplanations END


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy