com.mg.common.metadata.freeMarker.directive.FilesDirective Maven / Gradle / Ivy
package com.mg.common.metadata.freeMarker.directive;
import com.mg.common.metadata.service.MetaDataQueryService;
import com.mg.framework.entity.metadata.MirrorPropertyEntity;
import com.mg.framework.log.ContextLookup;
import com.mg.framework.entity.metadata.MTemplateTypeEnum;
import freemarker.core.Environment;
import freemarker.template.*;
import java.io.IOException;
import java.util.Map;
/**
* 图片类型的元数据
* Created by liukefu on 2015/9/28.
*/
public class FilesDirective extends BaseDirective {
@Override
public void execute(Environment env,
Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body)
throws TemplateException, IOException {
// Check if no parameters were given:
if (params.isEmpty()) {
throw new TemplateModelException("This directive need 'property' parameters.");
}
SimpleNumber propertyScalar = (SimpleNumber)params.get("property");
SimpleScalar templateTypeScalar = (SimpleScalar)params.get("templateType");
String property = propertyScalar.toString();
String templateType = MTemplateTypeEnum.DataEntry.toString();
if(templateTypeScalar!=null){
templateType = templateTypeScalar.getAsString();
}
//得到元数据
MetaDataQueryService metaDataQueryService = ContextLookup.getBean(MetaDataQueryService.class);
MirrorPropertyEntity mirrorProperty = metaDataQueryService.findMPropertyById(property);
StringBuilder sb = new StringBuilder();
//标题
sb.append("");
sb.append(createViewField(mirrorProperty));
//sb.append(" ");
sb.append("");
env.getOut().write(sb.toString());
}
public String createViewField(MirrorPropertyEntity mirrorProperty){
StringBuilder sb = new StringBuilder();
sb.append("");
return sb.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy