cancel
Showing results for 
Search instead for 
Did you mean: 

Facing issue while developing custom snap

maheswara
New Contributor

Hi Team,

I need small help related to custom snap. I started creating custom snap as per my requirement.i have created project and written a code for snap and deployed successfully. After that I have modified and added new functionality to that snap and again re-deployed. After all these I am getting some issues. Those are 

1.some times suggestions in snap not showing.its showing like loading suggestions that's it not showing anything.

2.some times preview not showing after validation.

3.some times preview showing based on last deployment code  not based on  latest deployment code.

 Could you please help on these issues. 

2 REPLIES 2

ddellsperger
Employee
Employee

I think a number of these are likely to be resolved by changing your build number prior to deployment. there's an `sl_build` baked into the pom (see here). This should be an ever-increasing value as it will then require the jcc download that new zip file whenever it runs. 

Your concerns for issue 1 are likely related to the fact that suggestions come from the snap pack being run on the jcc, so when you go to open a suggestion field, it will talk to the jcc (and the jcc will return back to the UI) the details potentially required to fill in the field. That can be slow, fast or not show sometimes depending on (usually) the size of your snap pack as that has to be downloaded by the jcc first.

I'd see if bumping your sl_build property fixes most (if not all) of these issues and if it doesn't, feel free to reply back and we can maybe investigate further.

Hi @ddellsperger,

Thank you for response. after changing build number also still i am getting same old deployment logic only and also some time not giving the output. 

package com.snaplogic.snaps.train;

import com.google.inject.Inject;
import com.snaplogic.api.ConfigurationException;
import com.snaplogic.api.ExecutionException;
import com.snaplogic.api.Snap;
import com.snaplogic.common.properties.Suggestions;
import com.snaplogic.common.properties.builders.PropertyBuilder;
import com.snaplogic.common.properties.builders.SuggestionBuilder;
import com.snaplogic.snap.api.DocumentUtility;
import com.snaplogic.snap.api.OutputViews;
import com.snaplogic.snap.api.PropertyCategory;
import com.snaplogic.snap.api.PropertyValues;
import com.snaplogic.snap.api.SnapCategory;
import com.snaplogic.snap.api.capabilities.Category;
import com.snaplogic.snap.api.capabilities.Errors;
import com.snaplogic.snap.api.capabilities.General;
import com.snaplogic.snap.api.capabilities.Inputs;
import com.snaplogic.snap.api.capabilities.Outputs;
import com.snaplogic.snap.api.capabilities.Version;
import com.snaplogic.snap.api.capabilities.ViewType;

import java.util.LinkedHashMap;
import java.util.Map;

/**
* This Snap has one output and writes one document that contains the suggested
* value.
*
* <p>This snap demonstrates the suggest value functionality that uses the
* partial configuration information to suggest a property value.</p>
*/
@Version(snap = 1)
@General(title = "Test", purpose = "Demo functionality.",
author = "Your Company Name", docLink = "http://yourdocslinkhere.com")
@Inputs(min = 0, max = 1, accepts = {ViewType.DOCUMENT})
@Outputs(min = 1, max = 1, offers = {ViewType.DOCUMENT})
@Errors(min = 1, max = 1, offers = {ViewType.DOCUMENT})
@Category(snap = SnapCategory.READ)
public class Suggest implements Snap {

public static final String PROP_ECHO = "echo";
public static String api = "https://sometest-ex.test.com/export/";
public static String ExpItem = "EZX_Snap_Export_Item";
public static String ExpItemLMD = "EZX_Snap_Export_Item_LMD";
public static String ExpItemLCD = "EZX_Snap_Export_LCD";
public String end = "";
private String valueToWrite;

@Inject
private DocumentUtility documentUtility;

@Inject
private OutputViews outputViews;

@Override
public void defineProperties(final PropertyBuilder propertyBuilder) {
propertyBuilder.describe(PROP_ECHO, PROP_ECHO)
.withSuggestions(new Suggestions() {
@Override
public void suggest(SuggestionBuilder suggestionBuilder,
PropertyValues propertyValues) {
suggestionBuilder.node(PROP_ECHO).suggestions("Export Item", "Export Item_LMD", "Export Item_LCD");
}
}).add();
}

@Override
public void configure(final PropertyValues propertyValues) throws ConfigurationException {
valueToWrite = propertyValues.get(PROP_ECHO);
}

@Override
public void execute() throws ExecutionException {
switch (valueToWrite) {
case "Export Item":
api += ExpItem;
break;
case "Export Item_LMD":
api += ExpItemLMD;
break;
case "Export Item_LCD":
api += ExpItemLCD;
break;
default:
// No op
}

Map<String, String> data = new LinkedHashMap<String, String>() {{
put("key", api);
}};
outputViews.write(documentUtility.newDocument(data));
}

@Override
public void cleanup() throws ExecutionException {
// NOOP
}
}

This is my code.