List of usage examples for com.liferay.portal.kernel.service ServiceContext getScopeGroupId
public long getScopeGroupId()
From source file:ch.inofix.contact.service.impl.ContactLocalServiceImpl.java
License:Open Source License
@Override @Indexable(type = IndexableType.REINDEX) public Contact addContact(long userId, String card, String uid, ServiceContext serviceContext) throws PortalException { // Contact/*from w ww. ja v a 2 s. com*/ User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); // TODO // validate(); long contactId = counterLocalService.increment(); Contact contact = contactPersistence.create(contactId); contact.setUuid(serviceContext.getUuid()); contact.setGroupId(groupId); contact.setCompanyId(user.getCompanyId()); contact.setUserId(user.getUserId()); contact.setUserName(user.getFullName()); contact.setExpandoBridgeAttributes(serviceContext); contact.setCard(card); contact.setUid(uid); contact = contactPersistence.update(contact); // Resources resourceLocalService.addModelResources(contact, serviceContext); // Asset updateAsset(userId, contact, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); // TODO // extraDataJSONObject.put("title", contact.getName()); socialActivityLocalService.addActivity(userId, groupId, Contact.class.getName(), contactId, ContactActivityKeys.ADD_CONTACT, extraDataJSONObject.toString(), 0); return contact; }
From source file:ch.inofix.contact.service.impl.ContactLocalServiceImpl.java
License:Open Source License
@Override @Indexable(type = IndexableType.REINDEX) public Contact updateContact(long userId, long contactId, String card, String uid, ServiceContext serviceContext) throws PortalException { // Contact/*from w w w.j av a 2 s .com*/ long groupId = serviceContext.getScopeGroupId(); Contact contact = contactPersistence.findByPrimaryKey(contactId); // TODO: validate the vCard string contact.setGroupId(groupId); contact.setExpandoBridgeAttributes(serviceContext); contact.setCard(card); contactPersistence.update(contact); // Asset updateAsset(userId, contact, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); // extraDataJSONObject.put("title", contact.getName()); socialActivityLocalService.addActivity(userId, groupId, Contact.class.getName(), contact.getContactId(), ContactActivityKeys.UPDATE_CONTACT, extraDataJSONObject.toString(), 0); return contact; }
From source file:ch.inofix.contact.service.impl.ContactServiceImpl.java
License:Open Source License
@Override public Contact addContact(String card, String uid, ServiceContext serviceContext) throws PortalException { ContactManagerPortletPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ContactManagerActionKeys.ADD_CONTACT); return contactLocalService.addContact(getUserId(), card, uid, serviceContext); }
From source file:ch.inofix.data.service.impl.MeasurementServiceImpl.java
License:Open Source License
@Override public Measurement addMeasurement(String data, String id, String name, Date timestamp, String unit, String value, ServiceContext serviceContext) throws PortalException { DataManagerPortletPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), MeasurementActionKeys.ADD_MEASUREMENT); return measurementLocalService.addMeasurement(getUserId(), data, id, name, timestamp, unit, value, serviceContext);/*from w w w . j av a 2 s . c om*/ }
From source file:ch.inofix.referencemanager.service.impl.BibliographyLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override//from w w w. ja v a 2s .com public Bibliography addBibliography(long userId, String title, String description, String urlTitle, String comments, String preamble, String strings, ServiceContext serviceContext) throws PortalException { // Bibliography User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); validate(groupId, urlTitle); long bibliographyId = counterLocalService.increment(); Bibliography bibliography = bibliographyPersistence.create(bibliographyId); bibliography.setUuid(serviceContext.getUuid()); bibliography.setGroupId(groupId); bibliography.setCompanyId(user.getCompanyId()); bibliography.setUserId(user.getUserId()); bibliography.setUserName(user.getFullName()); bibliography.setExpandoBridgeAttributes(serviceContext); bibliography.setTitle(title); bibliography.setDescription(description); bibliography.setUrlTitle(urlTitle); bibliography.setComments(comments); bibliography.setPreamble(preamble); bibliography.setStrings(strings); bibliographyPersistence.update(bibliography); // Resources resourceLocalService.addModelResources(bibliography, serviceContext); // Asset updateAsset(userId, bibliography, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", bibliography.getTitle()); socialActivityLocalService.addActivity(userId, groupId, Bibliography.class.getName(), bibliographyId, BibliographyActivityKeys.ADD_BIBLIOGRAPHY, extraDataJSONObject.toString(), 0); return bibliography; }
From source file:ch.inofix.referencemanager.service.impl.BibliographyLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) public Bibliography updateBibliography(long bibliographyId, long userId, String title, String description, String urlTitle, String comments, String preamble, String strings, ServiceContext serviceContext) throws PortalException { // Bibliography User user = userPersistence.findByPrimaryKey(userId); Bibliography bibliography = bibliographyPersistence.findByPrimaryKey(bibliographyId); long groupId = serviceContext.getScopeGroupId(); if (!bibliography.getUrlTitle().equals(urlTitle)) { // modified urlTitle validate(groupId, urlTitle);/*w w w .j av a 2 s.c o m*/ } bibliography.setUuid(serviceContext.getUuid()); bibliography.setGroupId(groupId); bibliography.setCompanyId(user.getCompanyId()); bibliography.setUserId(user.getUserId()); bibliography.setUserName(user.getFullName()); bibliography.setExpandoBridgeAttributes(serviceContext); bibliography.setTitle(title); bibliography.setDescription(description); bibliography.setUrlTitle(urlTitle); bibliography.setComments(comments); bibliography.setPreamble(preamble); bibliography.setStrings(strings); bibliographyPersistence.update(bibliography); // Resources resourceLocalService.addModelResources(bibliography, serviceContext); // Asset updateAsset(userId, bibliography, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", bibliography.getTitle()); socialActivityLocalService.addActivity(userId, groupId, Bibliography.class.getName(), bibliographyId, BibliographyActivityKeys.UPDATE_BIBLIOGRAPHY, extraDataJSONObject.toString(), 0); return bibliography; }
From source file:ch.inofix.referencemanager.service.impl.BibliographyServiceImpl.java
License:Open Source License
/** * //from ww w.ja v a2 s. com * @param userId * @param title * @param description * @param serviceContext * @return * @since 1.0.0 * @throws PortalException */ public Bibliography addBibliography(String title, String description, String urlTitle, String comments, String preamble, String strings, ServiceContext serviceContext) throws PortalException { BibliographyManagerPortletPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), BibliographyActionKeys.ADD_BIBLIOGRAPHY); return bibliographyLocalService.addBibliography(getUserId(), title, description, urlTitle, comments, preamble, strings, serviceContext); }
From source file:ch.inofix.referencemanager.service.impl.BibRefRelationLocalServiceImpl.java
License:Open Source License
public BibRefRelation addBibRefRelation(long userId, long bibliographyId, long referenceId, ServiceContext serviceContext) throws PortalException { // BibRefRelation User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); BibRefRelation bibRefRelation = null; bibRefRelation = bibRefRelationPersistence.fetchByB_R(bibliographyId, referenceId); if (bibRefRelation == null) { long bibRefRelationId = counterLocalService.increment(); bibRefRelation = bibRefRelationPersistence.create(bibRefRelationId); bibRefRelation.setUuid(serviceContext.getUuid()); bibRefRelation.setGroupId(groupId); bibRefRelation.setCompanyId(user.getCompanyId()); bibRefRelation.setUserId(user.getUserId()); bibRefRelation.setUserName(user.getFullName()); bibRefRelation.setExpandoBridgeAttributes(serviceContext); bibRefRelation.setBibliographyId(bibliographyId); bibRefRelation.setReferenceId(referenceId); bibRefRelationPersistence.update(bibRefRelation); // Update (and re-index) both parts of the relation bibliographyLocalService.reIndexBibligraphy(bibliographyId); referenceLocalService.reIndexReference(referenceId); } else {// w ww . ja v a 2 s.co m _log.info("The bibRefRelation already exists."); } return bibRefRelation; }
From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override//from w ww.j a v a 2 s . c om public Reference addReference(long userId, String bibTeX, long[] bibliographyIds, ServiceContext serviceContext) throws PortalException { // Reference User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); long companyId = user.getCompanyId(); long referenceId = counterLocalService.increment(); Reference reference = referencePersistence.create(referenceId); reference.setUuid(serviceContext.getUuid()); reference.setGroupId(groupId); reference.setCompanyId(companyId); reference.setUserId(user.getUserId()); reference.setUserName(user.getFullName()); reference.setExpandoBridgeAttributes(serviceContext); BibTeXEntry bibTeXEntry = BibTeXUtil.getBibTeXEntry(bibTeX); if (bibTeXEntry != null) { Key key = new Key("bibshare-id"); Value value = new StringValue(String.valueOf(referenceId), Style.QUOTED); bibTeXEntry.addField(key, value); } else { // TODO: raise an error and report to the user that something is // wrong with the bibtex-src. } bibTeX = BibTeXUtil.format(bibTeXEntry); reference.setBibTeX(bibTeX); referencePersistence.update(reference); // Match user and group references against common references long defaultGroupId = GetterUtil.getLong(PropsUtil.get("default.group.id")); if (reference.getGroupId() != defaultGroupId) { match(reference); } // BibRefRelation for (long bibliographyId : bibliographyIds) { Bibliography bibliography = bibliographyLocalService.getBibliography(bibliographyId); long bibRefRelationId = counterLocalService.increment(); BibRefRelation bibRefRelation = bibRefRelationPersistence.create(bibRefRelationId); bibRefRelation.setGroupId(bibliography.getGroupId()); bibRefRelation.setCompanyId(bibliography.getCompanyId()); bibRefRelation.setUserId(bibliography.getUserId()); bibRefRelation.setUserName(bibliography.getUserName()); bibRefRelation.setBibliographyId(bibliography.getBibliographyId()); bibRefRelation.setReferenceId(referenceId); bibRefRelationPersistence.update(bibRefRelation); } // Resources resourceLocalService.addModelResources(reference, serviceContext); // Asset updateAsset(userId, reference, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", reference.getCitation()); socialActivityLocalService.addActivity(userId, groupId, Reference.class.getName(), referenceId, ReferenceActivityKeys.ADD_REFERENCE, extraDataJSONObject.toString(), 0); return reference; }
From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) public Reference updateReference(long referenceId, long userId, String bibTeX, long[] bibliographyIds, ServiceContext serviceContext) throws PortalException { // Reference//from www. j a v a2s .c o m User user = userPersistence.findByPrimaryKey(userId); Reference reference = referencePersistence.findByPrimaryKey(referenceId); long groupId = serviceContext.getScopeGroupId(); long companyId = user.getCompanyId(); reference.setUuid(serviceContext.getUuid()); reference.setGroupId(groupId); reference.setCompanyId(companyId); reference.setUserId(user.getUserId()); reference.setUserName(user.getFullName()); reference.setExpandoBridgeAttributes(serviceContext); BibTeXEntry bibTeXEntry = BibTeXUtil.getBibTeXEntry(bibTeX); if (bibTeXEntry != null) { Key key = new Key("bibshare-last-modified"); Value value = new StringValue(String.valueOf(new Date().getTime()), Style.QUOTED); bibTeXEntry.addField(key, value); } else { // TODO: raise an error and report to the user that something is // wrong with the bibtex-src. } bibTeX = BibTeXUtil.format(bibTeXEntry); reference.setBibTeX(bibTeX); reference = referencePersistence.update(reference); // Match user and group references against common references long defaultGroupId = GetterUtil.getLong(PropsUtil.get("default.group.id")); if (reference.getGroupId() != defaultGroupId) { match(reference); } // BibRefRelation for (long bibliographyId : bibliographyIds) { Bibliography bibliography = bibliographyLocalService.getBibliography(bibliographyId); long bibRefRelationId = counterLocalService.increment(); BibRefRelation bibRefRelation = bibRefRelationPersistence.create(bibRefRelationId); bibRefRelation.setGroupId(bibliography.getGroupId()); bibRefRelation.setCompanyId(bibliography.getCompanyId()); bibRefRelation.setUserId(bibliography.getUserId()); bibRefRelation.setUserName(bibliography.getUserName()); bibRefRelation.setBibliographyId(bibliography.getBibliographyId()); bibRefRelation.setReferenceId(referenceId); bibRefRelationPersistence.update(bibRefRelation); } // Resources resourceLocalService.addModelResources(reference, serviceContext); // Asset updateAsset(userId, reference, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", reference.getCitation()); socialActivityLocalService.addActivity(userId, groupId, Reference.class.getName(), referenceId, ReferenceActivityKeys.UPDATE_REFERENCE, extraDataJSONObject.toString(), 0); return reference; }