@Override public void setObject(Object object) { Serializable reference = resolver.getReference(object); doc.setPropertyValue(xpath, reference); }
@Override public void mapProperties(CoreSession session, DocumentModel sourceDoc, DocumentModel targetDoc, String mapping) { Map<String, String> properties = getMapping(mapping); for (String keyProp : properties.keySet()) { // verify that mapping can be done Property sourceProperty = sourceDoc.getProperty(keyProp); Property targetProperty = targetDoc.getProperty(properties.get(keyProp)); Type sourceType = sourceProperty.getType(); Type targetType = targetProperty.getType(); if (!compatibleTypes(targetType, sourceType)) { throw new NuxeoException( String.format("Invalid mapping. Cannot map %s on type %s ", sourceType, targetType)); } targetDoc.setPropertyValue(targetProperty.getXPath(), sourceProperty.getValue()); } session.saveDocument(targetDoc); }
/** * @since 5.7.3 Alias for #setProperty. */ public void setPropertyValue(String key, Serializable value) { doc.setPropertyValue(key, value); }
@Override public void setIssuedDate(DocumentModel doc, Calendar issuedDate) { doc.setPropertyValue(DUBLINCORE_ISSUED_DATE_PROPERTY, issuedDate); }
@Override public void doCrop(String coords) { doc.setPropertyValue("picture:cropCoords", coords); }
/** * Clears the notification in the document's property. * * @since 10.2 */ protected void clearNotification() { doc.setPropertyValue(NOTIF_PROPERTY, null); }
private void initializeThread(DocumentModel thread) { // Update ttcth:lastCommentDate to set Thread first in list // (nb answers is set to 0 by default - schema definition) GregorianCalendar dateCreation = (GregorianCalendar) thread.getPropertyValue("dc:created"); thread.setPropertyValue(CollabToolsConstants.TTC_THREAD_LAST_COMMENT_DATE_XPATH, dateCreation); }
protected void setAnnotationProperties(DocumentModel annotationModel, Annotation annotation) { annotationModel.setPropertyValue(ANNOTATION_ID_PROPERTY, annotation.getId()); annotationModel.setPropertyValue(ANNOTATION_DOCUMENT_ID_PROPERTY, annotation.getDocumentId()); annotationModel.setPropertyValue(ANNOTATION_XPATH_PROPERTY, annotation.getXpath()); annotationModel.setPropertyValue(ANNOTATION_ENTITY_PROPERTY, annotation.getEntity()); }
@Override public String addComment() { DocumentModel myComment = documentManager.createDocumentModel(CommentsConstants.COMMENT_DOC_TYPE); myComment.setPropertyValue(CommentsConstants.COMMENT_AUTHOR, principal.getName()); myComment.setPropertyValue(CommentsConstants.COMMENT_TEXT, newContent); myComment.setPropertyValue(CommentsConstants.COMMENT_CREATION_DATE, Calendar.getInstance()); myComment = addComment(myComment); // do not navigate to newly-created comment, they are hidden documents return null; }
public void save(DocumentModel doc) { List<Map<String, Serializable>> bindings = new ArrayList<Map<String, Serializable>>(); for (TemplateBinding tb : this) { bindings.add(tb.getAsMap()); } doc.setPropertyValue(BINDING_PROP_NAME, (Serializable) bindings); } }
@Override public DocumentModel createComment(DocumentModel docModel, String comment, String author) { try (CloseableCoreSession session = CoreInstance.openCoreSessionSystem(docModel.getRepositoryName())) { DocumentModel commentDM = session.createDocumentModel(COMMENT_DOC_TYPE); commentDM.setPropertyValue(CommentsConstants.COMMENT_TEXT, comment); commentDM.setPropertyValue(CommentsConstants.COMMENT_AUTHOR, author); commentDM.setPropertyValue(CommentsConstants.COMMENT_CREATION_DATE, Calendar.getInstance()); commentDM = internalCreateComment(session, docModel, commentDM, null); session.save(); return commentDM; } }
@Override public void setModificationDate(DocumentModel doc, Calendar modificationDate) { doc.setPropertyValue(DUBLINCORE_MODIFIED_DATE_PROPERTY, modificationDate); if (doc.getPropertyValue(DUBLINCORE_CREATED_DATE_PROPERTY) == null) { setCreationDate(doc, modificationDate); } }
@SuppressWarnings("unchecked") public DocumentModel addComment(DocumentModel comment, String path) { comment.setPropertyValue(COMMENT_PARENT_ID, docModel.getId()); return commentManager.createLocatedComment(docModel, comment, path); }
protected void resetProperties(DocumentModel doc) throws IOException { log.debug(String.format("Resetting video info, storyboard, previews and conversions of document %s.", doc)); VideoHelper.updateVideoInfo(doc, null); VideoHelper.updateStoryboard(doc, null); VideoHelper.updatePreviews(doc, null); doc.setPropertyValue(TRANSCODED_VIDEOS_PROPERTY, null); }
@Override public void run() { DocumentModel doc = session.getSourceDocument(docRef); if (doc != null) { doc.setPropertyValue(xpath, value); session.saveDocument(doc); } }
@Observer(value = {EventNames.NEW_DOCUMENT_CREATED}) public void initShowInMenu() throws NuxeoException { final DocumentModel newDocument = navigationContext.getChangeableDocument(); if (newDocument.hasFacet(ToutaticeNuxeoStudioConst.CST_FACET_SPACE_NAVIGATION_ITEM) || "Folder".equals(newDocument.getType()) || "OrderedFolder".equals(newDocument.getType())) { newDocument.setPropertyValue(ToutaticeNuxeoStudioConst.CST_DOC_XPATH_TOUTATICE_SIM, true); if ("PortalSite".equals(newDocument.getType())) { newDocument.setPropertyValue(ToutaticeNuxeoStudioConst.CST_DOC_XPATH_TOUTATICE_INTERNAL_CONTEXTUALIZATION, true); } } }
@Observer(value = { EventNames.NEW_DOCUMENT_CREATED }, create = false) public void onDocumentCreation() { resetBeanCache(null); DocumentModel currentDoc = getCurrentDocument(); if (null != currentDoc) { try { currentDoc.setPropertyValue(NuxeoStudioConst.CST_DOC_XPATH_STAGE_LIFE_CYCLE, "HorsLigne"); } catch (Exception e) { e.printStackTrace(); } } }
private void resetSchemaProperties(DocumentModel target) throws OperationException { if (xpath != null) { target.setPropertyValue(xpath, null); } else if (schema != null) { for (String key : target.getProperties(schema).keySet()) { target.setProperty(schema, key, null); } } else { throw new OperationException("No schema or xpath was provided"); } }
@Override public void removeForcedType(String type, boolean save) { List<String> types = getForcedTypes(); if (types.contains(type)) { types.remove(type); String[] typesArray = types.toArray(new String[types.size()]); getAdaptedDoc().setPropertyValue(TemplateSourceDocumentAdapterImpl.TEMPLATE_FORCED_TYPES_PROP, typesArray); if (save) { adaptedDoc = getAdaptedDoc().getCoreSession().saveDocument(getAdaptedDoc()); } } }
public String doSimpleSearch() { setSearchMainTab(null); currentContentViewName = SIMPLE_SEARCH_CONTENT_VIEW_NAME; ContentView contentView = contentViewActions.getContentView(SIMPLE_SEARCH_CONTENT_VIEW_NAME); DocumentModel searchDoc = contentView.getSearchDocumentModel(); searchDoc.setPropertyValue("defaults:ecm_fulltext", simpleSearchKeywords); refreshAndRewind(); return "search"; }