本文整理汇总了Java中org.ndexbio.model.object.NdexProvenanceEventType类的典型用法代码示例。如果您正苦于以下问题:Java NdexProvenanceEventType类的具体用法?Java NdexProvenanceEventType怎么用?Java NdexProvenanceEventType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NdexProvenanceEventType类属于org.ndexbio.model.object包,在下文中一共展示了NdexProvenanceEventType类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseFile
import org.ndexbio.model.object.NdexProvenanceEventType; //导入依赖的package包/类
@Override
public void parseFile() throws NdexException {
try (CXNetworkLoader loader = new CXNetworkLoader(new FileInputStream(fileName), ownerAccountName)) {
uuid = loader.persistCXNetwork();
try (NetworkDocDAO dao = new NetworkDocDAO()) {
NetworkSummary currentNetwork = dao.getNetworkSummaryById(uuid.toString());
String uri = NdexDatabase.getURIPrefix();
@SuppressWarnings("resource")
UserDocDAO userDocDAO = new UserDocDAO(dao.getDBConnection()) ;
User loggedInUser = userDocDAO.getUserByAccountName(ownerAccountName);
ProvenanceEntity provEntity = ProvenanceHelpers.createProvenanceHistory(currentNetwork,
uri, NdexProvenanceEventType.FILE_UPLOAD, currentNetwork.getCreationTime(),
(ProvenanceEntity)null);
Helper.populateProvenanceEntity(provEntity, currentNetwork);
provEntity.getCreationEvent().setEndedAtTime(currentNetwork.getModificationTime());
List<SimplePropertyValuePair> l = provEntity.getCreationEvent().getProperties();
Helper.addUserInfoToProvenanceEventProperties( l, loggedInUser);
l.add( new SimplePropertyValuePair ( "filename",description) );
loader.setNetworkProvenance(provEntity);
}
} catch ( Exception e) {
e.printStackTrace();
throw new NdexException ("Failed to load CX file. " + e.getMessage());
}
}
示例2: createCXNetwork
import org.ndexbio.model.object.NdexProvenanceEventType; //导入依赖的package包/类
@POST
// @PermitAll
@Path("")
@Produces("text/plain")
@Consumes("multipart/form-data")
@ApiDoc("Create a network from the uploaded CX stream. The input cx data is expected to be in the CXNetworkStream field of posted multipart/form-data. "
+ "There is an optional 'provenance' field in the form. Users can use this field to pass in a JSON string of ProvenanceEntity object. When a user pass"
+ " in this object, NDEx server will add this object to the provenance history of the CX network. Otherwise NDEx server will create a ProvenanceEntity "
+ "object and add it to the provenance history of the CX network.")
public Response createCXNetwork( MultipartFormDataInput input,
@QueryParam("visibility") String visibilityStr,
@QueryParam("indexedfields") String fieldListStr // comma seperated list
) throws Exception
{
VisibilityType visibility = null;
if ( visibilityStr !=null) {
visibility = VisibilityType.valueOf(visibilityStr);
}
Set<String> extraIndexOnNodes = null;
if ( fieldListStr != null) {
extraIndexOnNodes = new HashSet<>(10);
for ( String f: fieldListStr.split("\\s*,\\s*") ) {
extraIndexOnNodes.add(f);
}
}
try (UserDAO dao = new UserDAO()) {
dao.checkDiskSpace(getLoggedInUserId());
}
UUID uuid = storeRawNetwork ( input);
String uuidStr = uuid.toString();
accLogger.info("[data]\t[uuid:" +uuidStr + "]" );
String urlStr = Configuration.getInstance().getHostURI() +
Configuration.getInstance().getRestAPIPrefix()+"/network/"+ uuidStr;
ProvenanceEntity entity = new ProvenanceEntity();
entity.setUri(urlStr + "/summary");
String cxFileName = Configuration.getInstance().getNdexRoot() + "/data/" + uuidStr + "/network.cx";
long fileSize = new File(cxFileName).length();
// create entry in db.
try (NetworkDAO dao = new NetworkDAO()) {
NetworkSummary summary = dao.CreateEmptyNetworkEntry(uuid, getLoggedInUser().getExternalId(), getLoggedInUser().getUserName(), fileSize);
ProvenanceEvent event = new ProvenanceEvent(NdexProvenanceEventType.CX_CREATE_NETWORK, summary.getModificationTime());
List<SimplePropertyValuePair> eventProperties = new ArrayList<>();
eventProperties.add( new SimplePropertyValuePair("user name", this.getLoggedInUser().getUserName()) ) ;
event.setProperties(eventProperties);
entity.setCreationEvent(event);
dao.setProvenance(summary.getExternalId(), entity);
dao.commit();
}
NdexServerQueue.INSTANCE.addSystemTask(new CXNetworkLoadingTask(uuid, getLoggedInUser().getUserName(), false, visibility, extraIndexOnNodes));
// logger.info("[end: Created a new network based on a POSTed CX stream.]");
URI l = new URI (urlStr);
return Response.created(l).entity(l).build();
}
示例3: createCXNetwork
import org.ndexbio.model.object.NdexProvenanceEventType; //导入依赖的package包/类
@POST
// @PermitAll
@Path("/asCX")
// @Produces("application/json")
@Produces("text/plain")
@Consumes("multipart/form-data")
@ApiDoc("Create a network from the uploaded CX stream. The input cx data is expected to be in the CXNetworkStream field of posted multipart/form-data. "
+ "There is an optional 'provenance' field in the form. Users can use this field to pass in a JSON string of ProvenanceEntity object. When a user pass"
+ " in this object, NDEx server will add this object to the provenance history of the CX network. Otherwise NDEx server will create a ProvenanceEntity "
+ "object and add it to the provenance history of the CX network.")
public String createCXNetwork( MultipartFormDataInput input) throws Exception
{
// logger.info("[start: Creating a new network based on a POSTed CX stream.]");
try (UserDAO dao = new UserDAO()) {
dao.checkDiskSpace(getLoggedInUserId());
}
UUID uuid = storeRawNetwork ( input);
String uuidStr = uuid.toString();
accLogger.info("[data]\t[uuid:" +uuidStr + "]" );
String urlStr = Configuration.getInstance().getHostURI() +
Configuration.getInstance().getRestAPIPrefix()+"/network/"+ uuidStr;
ProvenanceEntity entity = new ProvenanceEntity();
entity.setUri(urlStr + "/summary");
String cxFileName = Configuration.getInstance().getNdexRoot() + "/data/" + uuidStr + "/network.cx";
long fileSize = new File(cxFileName).length();
// create entry in db.
try (NetworkDAO dao = new NetworkDAO()) {
NetworkSummary summary = dao.CreateEmptyNetworkEntry(uuid, getLoggedInUser().getExternalId(), getLoggedInUser().getUserName(), fileSize);
ProvenanceEvent event = new ProvenanceEvent(NdexProvenanceEventType.CX_CREATE_NETWORK, summary.getModificationTime());
List<SimplePropertyValuePair> eventProperties = new ArrayList<>();
eventProperties.add( new SimplePropertyValuePair("user name", this.getLoggedInUser().getUserName()) ) ;
event.setProperties(eventProperties);
entity.setCreationEvent(event);
dao.setProvenance(summary.getExternalId(), entity);
dao.commit();
} catch (Throwable e) {
e.printStackTrace();
throw e;
}
NdexServerQueue.INSTANCE.addSystemTask(new CXNetworkLoadingTask(uuid, getLoggedInUser().getUserName(), false, null,null));
// logger.info("[end: Created a new network based on a POSTed CX stream.]");
//return "\"" + uuidStr + "\"";
return uuidStr ;
}
示例4: parseFile
import org.ndexbio.model.object.NdexProvenanceEventType; //导入依赖的package包/类
@Override
public void parseFile() throws NdexException {
this.entityCount = 0;
this.pubXrefCount = 0;
this.uXrefCount = 0;
this.rXrefCount = 0;
// this.literalPropertyCount = 0;
// this.referencePropertyCount = 0;
try {
this.getMsgBuffer()
.add("Parsing lines from " + this.getBioPAXURI());
this.processBioPAX(this.getBioPAXFile());
// add provenance to network
NetworkSummary currentNetwork = this.persistenceService
.getCurrentNetwork();
// set the source format
this.persistenceService.setNetworkSourceFormat(NetworkSourceFormat.BIOPAX);
String uri = NdexDatabase.getURIPrefix();
this.persistenceService.setNetworkVisibility(VisibilityType.PRIVATE);
ProvenanceEntity provEntity = ProvenanceHelpers
.createProvenanceHistory(currentNetwork, uri,
NdexProvenanceEventType.FILE_UPLOAD, currentNetwork.getCreationTime(),
(ProvenanceEntity) null);
Helper.populateProvenanceEntity(provEntity, currentNetwork);
provEntity.getCreationEvent().setEndedAtTime(
currentNetwork.getModificationTime());
List<SimplePropertyValuePair> l = provEntity.getCreationEvent()
.getProperties();
Helper.addUserInfoToProvenanceEventProperties( l, loggedInUser);
l.add(new SimplePropertyValuePair("filename", this.description));
this.persistenceService.setNetworkProvenance(provEntity);
// close database connection
this.persistenceService.persistNetwork();
persistenceService.commit();
System.out.println("Network UUID: " + currentNetwork.getExternalId());
this.networkUUID = currentNetwork.getExternalId().toString();
} catch (Exception e) {
// delete network and close the database connection
e.printStackTrace();
this.persistenceService.abortTransaction();
throw new NdexException("Error occurred when loading file "
+ this.bioPAXFile.getName() + ". " + e.getMessage());
}
finally
{
persistenceService.close();
}
}
示例5: parseFile
import org.ndexbio.model.object.NdexProvenanceEventType; //导入依赖的package包/类
@Override
public void parseFile() throws NdexException
{
try
{
this.processHeaderAndCreateNetwork();
this.processNamespaces();
this.processAnnotationDefinitions();
this.processStatementGroups();
//add provenance to network
NetworkSummary currentNetwork = this.networkService.getCurrentNetwork();
String uri = NdexDatabase.getURIPrefix();
// set edge count and node count,
// then close database connection
this.networkService.persistNetwork();
ProvenanceEntity provEntity = ProvenanceHelpers.createProvenanceHistory(currentNetwork,
uri, NdexProvenanceEventType.FILE_UPLOAD, currentNetwork.getCreationTime(),
(ProvenanceEntity)null);
Helper.populateProvenanceEntity(provEntity, currentNetwork);
provEntity.getCreationEvent().setEndedAtTime(currentNetwork.getModificationTime());
File f = new File (this.xmlFile);
List<SimplePropertyValuePair> l = provEntity.getCreationEvent().getProperties();
Helper.addUserInfoToProvenanceEventProperties( l, loggedInUser);
l.add( new SimplePropertyValuePair ( "filename",this.description) );
this.networkService.setNetworkProvenance(provEntity);
networkService.commit();
}
catch (Exception e)
{
e.printStackTrace();
// rollback current transaction and close the database connection
this.networkService.abortTransaction();
throw new NdexException ("Error occurred when loading " +
xmlFile + ". " + e.getMessage());
}
finally
{
networkService.close();
}
}
示例6: parseFile
import org.ndexbio.model.object.NdexProvenanceEventType; //导入依赖的package包/类
@Override
public void parseFile() throws NdexException {
try (FileInputStream xgmmlFileStream = new FileInputStream(this.getXgmmlFile())) {
try
{
setNetwork();
readXGMML(xgmmlFileStream);
// set the source format
this.networkService.setNetworkSourceFormat(NetworkSourceFormat.XGMML);
//add provenance to network
NetworkSummary currentNetwork = this.networkService.getCurrentNetwork();
String uri = NdexDatabase.getURIPrefix();
// close database connection
this.networkService.persistNetwork();
ProvenanceEntity provEntity = ProvenanceHelpers.createProvenanceHistory(currentNetwork,
uri,NdexProvenanceEventType.FILE_UPLOAD,
currentNetwork.getCreationTime(), (ProvenanceEntity)null);
Helper.populateProvenanceEntity(provEntity, currentNetwork);
provEntity.getCreationEvent().setEndedAtTime(currentNetwork.getModificationTime());
List<SimplePropertyValuePair> l = provEntity.getCreationEvent().getProperties();
Helper.addUserInfoToProvenanceEventProperties( l, loggedInUser);
l.add( new SimplePropertyValuePair ( "filename",this.description) );
this.networkService.setNetworkProvenance(provEntity);
networkService.commit();
}
catch (Exception e)
{
// rollback current transaction and close the database connection
this.networkService.abortTransaction();
e.printStackTrace();
throw new NdexException("Error occurred when loading "
+ this.xgmmlFile.getName() + ". " + e.getMessage());
}
} catch (IOException e1) {
e1.printStackTrace();
log("Could not read " + this.getXgmmlFile() + ": " + e1.getMessage());
this.networkService.abortTransaction();
throw new NdexException("File not found: " + this.xgmmlFile.getName());
}
finally
{
networkService.close();
}
}
示例7: parseFile
import org.ndexbio.model.object.NdexProvenanceEventType; //导入依赖的package包/类
/**************************************************************************
* Whitespace (space or tab) is used to delimit the names in the simple
* interaction file format. However, in some cases spaces are desired in a
* node name or edge type. The standard is that, if the file contains any
* tab characters, then tabs are used to delimit the fields and spaces are
* considered part of the name. If the file contains no tabs, then any
* spaces are delimiters that separate names (and names cannot contain
* spaces).
* @throws JsonProcessingException
* @throws NdexException
**************************************************************************/
@Override
public void parseFile() throws NdexException {
try (BufferedReader bufferedReader =
new BufferedReader(new FileReader(this.getSifFile()))){
this.getMsgBuffer().add("Parsing lines from " + this.getSIFURI());
boolean extendedBinarySIF = checkForExtendedFormat();
if (extendedBinarySIF) {
this.processExtendedBinarySIF(bufferedReader);
// this.networkService.setFormat("EXTENDED_BINARY_SIF");
} else {
boolean tabDelimited = scanForTabs();
this.processSimpleSIFLines(tabDelimited, bufferedReader);
// this.networkService.setFormat("BINARY_SIF");
}
//add provenance to network
NetworkSummary currentNetwork = this.persistenceService.getCurrentNetwork();
// set the source format
this.persistenceService.setNetworkSourceFormat(NetworkSourceFormat.SIF);
String uri = NdexDatabase.getURIPrefix();
// close database connection
this.persistenceService.persistNetwork();
ProvenanceEntity provEntity = ProvenanceHelpers.createProvenanceHistory(currentNetwork,
uri, NdexProvenanceEventType.FILE_UPLOAD, currentNetwork.getCreationTime(),
(ProvenanceEntity)null);
Helper.populateProvenanceEntity(provEntity, currentNetwork);
provEntity.getCreationEvent().setEndedAtTime(currentNetwork.getModificationTime());
List<SimplePropertyValuePair> l = provEntity.getCreationEvent().getProperties();
Helper.addUserInfoToProvenanceEventProperties( l, loggedInUser);
l.add( new SimplePropertyValuePair ( "filename",taskDescription) );
this.persistenceService.setNetworkProvenance(provEntity);
persistenceService.commit();
} catch (Exception e) {
// delete network and close the database connection
e.printStackTrace();
this.persistenceService.abortTransaction();
throw new NdexException("Error occurred when loading file " +
this.sifFile.getName() + ". " + e.getMessage() );
}
finally
{
persistenceService.close();
}
}