Let OverlayModels access the Project at deserialization time
This commit is contained in:
parent
99e98a2e78
commit
121661e8eb
@ -33,7 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
package com.google.refine.model;
|
package com.google.refine.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overlay models must be serializable and deserializable with Jackson.
|
||||||
|
* It is possible to have access to the project at deserialization time
|
||||||
|
* by adding the corresponding parameter to the JSON creator with
|
||||||
|
* @JacksonInject("project").
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface OverlayModel {
|
public interface OverlayModel {
|
||||||
public void onBeforeSave(Project project);
|
public void onBeforeSave(Project project);
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ import java.util.Properties;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.InjectableValues;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.google.refine.ProjectManager;
|
import com.google.refine.ProjectManager;
|
||||||
import com.google.refine.ProjectMetadata;
|
import com.google.refine.ProjectMetadata;
|
||||||
import com.google.refine.RefineServlet;
|
import com.google.refine.RefineServlet;
|
||||||
@ -188,6 +190,10 @@ public class Project {
|
|||||||
Project project = new Project(id);
|
Project project = new Project(id);
|
||||||
int maxCellCount = 0;
|
int maxCellCount = 0;
|
||||||
|
|
||||||
|
ObjectMapper mapper = ParsingUtilities.mapper.copy();
|
||||||
|
InjectableValues injections = new InjectableValues.Std().addValue("project", project);
|
||||||
|
mapper.setInjectableValues(injections);
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
int equal = line.indexOf('=');
|
int equal = line.indexOf('=');
|
||||||
|
Loading…
Reference in New Issue
Block a user