
com.adobe.aemds.guide.model.TextVariable Maven / Gradle / Ivy
/*
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2017 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
*/
package com.adobe.aemds.guide.model;
import com.adobe.aemds.guide.utils.GuideConstants;
import com.day.cq.wcm.msm.api.MSMNameConstants;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
import org.apache.sling.models.annotations.injectorspecific.ResourcePath;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
/**
* @pad.exclude Exclude from Published API.
*/
@Model(adaptables = Resource.class)
public class TextVariable {
@Inject @Optional
private String name;
@Inject @Optional
private String bindRef;
@Inject @Optional @Named(GuideConstants._VALUE)
private String defaultValue;
@Inject @Optional @Named(MSMNameConstants.PN_MASTER)
private String master;
private String dataType;
private String displayPictureClause;
@Self
private Resource resource;
private static Logger logger = LoggerFactory.getLogger(TextVariable.class);
public String getName() {
return name;
}
public String getBindRef() {
return bindRef;
}
public String getDefaultValue() {
return defaultValue;
}
public String getMaster() {
return master;
}
public String getDataType() {
return dataType;
}
public Resource getResource() {
return resource;
}
public String getVariableId() {
return getResource().getName();
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getDisplayPictureClause() {
return displayPictureClause;
}
public void setDisplayPictureClause(String displayPictureClause) {
this.displayPictureClause = displayPictureClause;
}
public boolean isLocked() {
//TODO: ideally should be ChannelSynchronizationUtils.isLocked(resource);
// but chanel core is dependent on guide-core, hence above would need to be moved.
return true;
}
public JSONObject toJSON() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put(GuideConstants.VARIABLE_ID, getVariableId());
jsonObject.put(GuideConstants.NAME, getName());
jsonObject.put(GuideConstants.BIND_REF, getBindRef());
jsonObject.put(GuideConstants.DATA_TYPE, getDataType());
jsonObject.put(GuideConstants._VALUE, getDefaultValue());
jsonObject.put(GuideConstants.VARIABLE_DISPLAY_PICTURE_CLAUSE,getDisplayPictureClause());
} catch (JSONException exception) {
logger.error("Error during creation of text variable.", exception);
}
return jsonObject;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy