com.sitewhere.microservice.scripting.ScriptTemplateManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sitewhere-microservice Show documentation
Show all versions of sitewhere-microservice Show documentation
SiteWhere Microservice Components Library
The newest version!
/**
* Copyright © 2014-2021 The SiteWhere Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sitewhere.microservice.scripting;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sitewhere.microservice.lifecycle.LifecycleComponent;
import com.sitewhere.spi.SiteWhereException;
import com.sitewhere.spi.microservice.lifecycle.ILifecycleProgressMonitor;
import com.sitewhere.spi.microservice.lifecycle.LifecycleComponentType;
import com.sitewhere.spi.microservice.scripting.IScriptTemplate;
import com.sitewhere.spi.microservice.scripting.IScriptTemplateManager;
/**
* Manages the list of script templates for a microservice.
*/
public class ScriptTemplateManager extends LifecycleComponent implements IScriptTemplateManager {
/** Map of script templates by template id */
private Map scriptTemplatesById = new HashMap();
public ScriptTemplateManager() {
super(LifecycleComponentType.ScriptTemplateManager);
}
/*
* @see
* com.sitewhere.microservice.lifecycle.LifecycleComponent#start(com.sitewhere.
* spi.microservice.lifecycle.ILifecycleProgressMonitor)
*/
@Override
public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException {
// Initialize scripts templates.
}
/*
* @see com.sitewhere.spi.microservice.scripting.IScriptTemplateManager#
* getScriptTemplates()
*/
@Override
public List getScriptTemplates() throws SiteWhereException {
List templates = new ArrayList(getScriptTemplatesById().values());
Collections.sort(templates, new Comparator() {
@Override
public int compare(IScriptTemplate o1, IScriptTemplate o2) {
return o1.getName().compareTo(o2.getName());
}
});
return templates;
}
/*
* @see com.sitewhere.spi.microservice.scripting.IScriptTemplateManager#
* getScriptTemplateContent(java.lang.String)
*/
@Override
public byte[] getScriptTemplateContent(String id) throws SiteWhereException {
return new byte[0];
}
protected Map getScriptTemplatesById() {
return scriptTemplatesById;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy