org.bidib.wizard.common.labels.DefaultWizardLabelWrapper Maven / Gradle / Ivy
package org.bidib.wizard.common.labels;
import java.io.File;
import org.bidib.jbidibc.core.schema.bidibbase.DefaultLabelsActionType;
import org.bidib.jbidibc.core.schema.bidiblabels.NodeLabels;
import org.bidib.jbidibc.messages.SoftwareVersion;
import org.bidib.jbidibc.messages.enums.PortModelEnum;
import org.bidib.jbidibc.messages.utils.ByteUtils;
import org.bidib.wizard.common.labels.DefaultWizardLabelFactory.DefaultLabelsApplied;
import org.bidib.wizard.common.labels.DefaultWizardLabelFactory.VersionedDefaultNodeLabelsWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DefaultWizardLabelWrapper implements WizardLabelWrapper {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultWizardLabelWrapper.class);
private final WizardLabelFactory wizardLabelFactory;
public DefaultWizardLabelWrapper(final WizardLabelFactory wizardLabelFactory) {
LOGGER.info("Create instance of DefaultWizardLabelWrapper.");
this.wizardLabelFactory = wizardLabelFactory;
}
@Override
public WizardLabelFactory getWizardLabelFactory() {
return this.wizardLabelFactory;
}
/**
* Load all labels.
*
* @param uniqueId
* the uniqueId of the node
*/
@Override
public NodeLabels loadLabels(Long uniqueId) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Load all labels for uniqueId: {}", ByteUtils.formatHexUniqueId(uniqueId));
}
return wizardLabelFactory.loadLabels(uniqueId);
}
@Override
public void saveNodeLabels(Long uniqueId) {
wizardLabelFactory.saveLabels(uniqueId);
}
@Override
public void deleteNodeLabels(Long uniqueId) {
wizardLabelFactory.deleteLabels(uniqueId);
}
/**
* Check if the default labels are applied.
*
* @param uniqueId
* the unique id of the node
* @return default labels applied
*/
@Override
public DefaultLabelsApplied getDefaultLabelsApplied(Long uniqueId) {
final DefaultLabelsApplied defaultLabelsApplied = wizardLabelFactory.getDefaultLabelsApplied(uniqueId);
return defaultLabelsApplied;
}
@Override
public void setDefaultLabelsApplied(
String lang, Long uniqueId, final SoftwareVersion softwareVersion, int relevantPidBits,
final PortModelEnum portModel, DefaultLabelsActionType defaultLabelsAction) {
wizardLabelFactory
.setDefaultLabelsApplied(uniqueId, softwareVersion, lang, relevantPidBits, portModel, defaultLabelsAction);
}
@Override
public VersionedDefaultNodeLabelsWrapper isDefaultLabelsAvailable(
final String lang, Long uniqueId, final SoftwareVersion softwareVersion, int relevantPidBits) {
return wizardLabelFactory.isDefaultLabelsAvailable(lang, uniqueId, softwareVersion, relevantPidBits);
}
@Override
public NodeLabels prepareDefaultLabels(Long uniqueId) {
return wizardLabelFactory.prepareDefaultLabels(uniqueId);
}
@Override
public void saveDefaultLabels(final NodeLabels nodeLabels, final File file) {
wizardLabelFactory.saveDefaultLabels(nodeLabels, file);
}
}