-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2136 from openturing/sprinklr/asset
Sprinklr/asset
- Loading branch information
Showing
7 changed files
with
370 additions
and
40 deletions.
There are no files selected for viewing
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
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
56 changes: 56 additions & 0 deletions
56
...nklr/sprinklr-app/src/main/java/com/viglet/turing/connector/sprinklr/utils/FileAsset.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,56 @@ | ||
package com.viglet.turing.connector.sprinklr.utils; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.net.URL; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Represents a File Asset extracted from Sprinklr Knowledge Base search result. | ||
* @author Gabriel F. Gomazako | ||
* @since 0.3.9 | ||
*/ | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class FileAsset { | ||
private String id; | ||
private String filename; | ||
private String ocrContent; | ||
private Date indexingDate; | ||
private Date modificationDate; | ||
private URL url; | ||
private long fileSize; | ||
private String extension; | ||
private String assetType; | ||
private String assetCategory; | ||
|
||
/** | ||
* Converts this FileAsset to an attribute map. | ||
* @return the attribute map. | ||
*/ | ||
public Map<String, Object> toMapAttributes() { | ||
var attributes = new HashMap<String, Object>(); | ||
|
||
var formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); | ||
String formatedIndexingDate = formatter.format(indexingDate); | ||
String formatedModificationDate = formatter.format(modificationDate); | ||
|
||
attributes.put("id", id); | ||
attributes.put("title", filename); | ||
attributes.put("text", ocrContent); | ||
attributes.put("publication_date", formatedIndexingDate); | ||
attributes.put("modification_date", formatedModificationDate); | ||
attributes.put("url", url); | ||
attributes.put("filesize", fileSize); | ||
attributes.put("extension", extension); | ||
attributes.put("source_apps", List.of("SPRINKLR")); | ||
attributes.put("type", "Static File"); | ||
|
||
return attributes; | ||
} | ||
} |
Oops, something went wrong.