-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flatten pmUsers and endUsers on CohortComplete nodes (#1181)
Signed-off-by: Angelica Ochoa <[email protected]>
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
model/src/main/java/org/mskcc/smile/model/converter/ArrayStringConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.mskcc.smile.model.converter; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.neo4j.ogm.typeconversion.AttributeConverter; | ||
|
||
/** | ||
* | ||
* @author ochoaa | ||
*/ | ||
public class ArrayStringConverter implements AttributeConverter<List<String>, String> { | ||
private final ObjectMapper mapper = new ObjectMapper(); | ||
private static final Log LOG = LogFactory.getLog(ArrayStringConverter.class); | ||
|
||
@Override | ||
public String toGraphProperty(List<String> value) { | ||
String toReturn = null; | ||
try { | ||
toReturn = mapper.writeValueAsString(value); | ||
} catch (JsonProcessingException ex) { | ||
LOG.error(ex); | ||
} | ||
return toReturn; | ||
} | ||
|
||
@Override | ||
public List<String> toEntityAttribute(String value) { | ||
List<String> toReturn = null; | ||
try { | ||
toReturn = Arrays.asList(mapper.readValue(value, String[].class)); | ||
} catch (Exception ex) { | ||
LOG.error(ex); | ||
} | ||
return toReturn; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters