I'm implementing web app using spring boot and quartz to allow registered users schedule notifications. These notifications are divided into two categories: sms and email. I would like to make possibility to choose category sms or email and then list all scheduled notifications by category. User can edit already scheduled notifications, add new ones and remove choosen ones. Task seems to be very simple, but I don't know how to assign job to user and category, since when I create new job there is possibility to identify jobs by job id and group name only. See the following code snipped:
private JobDetail createJob(ScheduleEmailDto scheduleEmailDto) {
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("email", scheduleEmailDto.getEmail());
jobDataMap.put("subject", scheduleEmailDto.getSubject());
jobDataMap.put("body", scheduleEmailDto.getBody());
Integer userId = scheduleEmailDto.getUserId();
Integer categoryId = scheduleEmailDto.getCategoryId();
JobDetail newJob = JobBuilder.newJob(EmailJob.class)
.withIdentity(UUID.randomUUID().toString(), "group")
.usingJobData(jobDataMap)
.storeDurably()
.build();
return newJob;
}
Does anyone is able to point me how can I assign newly created job to user and category? All suggestions would be very helpful.
If you don't already, you can configure a JDBCJobStore, which allows to save job_details, triggers and so on in a few database tables and handle them from DB.
See http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-09.html for more details.
At that point it could be easy for you to make an additional table which can link user and category to the jobs and manage them via DB.
Related
I've a multi-tenant app where the our customers submit their orders (JSON payload), which has to be processed offline. We're using database per tenant strategy and have configuration working all fine. However for asynchronous processing like in this example, we're stuck. When payload is submitted by the customer, it's saved into a table. We want to run a scheduled task, that can read this table and process the orders in their.
We tried something like:
#Scheduled(fixedRate = 60000)
public void doSomething() {
TenantDataSource tenantDataSource = context.getBean(TenantDataSource.class);
Set<String> tenants = tenantDataSource.getAll().keySet();
tenants.forEach(tenant -> {
MDC.setContext(new CallContext().setTenantId(tenant));
context.getBean(JobService.class).listJobs();
});
}
But this still looks for the jobs in the master database and not in the tenant specific database.
Any pointers?
Make sure the doSomething() method isn't transactional as transactional would create its own interceptor rather than looking into your resolver.
There is a possibility to call an on-demand workflow from CRM advanced find screen.
To initiate a workflow, user needs to select records first.
How to pass the selected data to the custom workflow?
e.g.
When you run Workflow with trigger such as Create or Record or Update of Record or Record assigned or so on i.e automatic trigger, Workflow Activity will have Input Parameter as Target i.e context of Record from which workflow is triggered. In Target you can find info such as record Id, Fields and so on.
But when you run OnDemand workflow, Workflow Activity will not contain Input parameter and hence details such as field and so on from which record it is fired will not be available.
You will only receive few info such as Record Id, Record Logical Name but not field detials.
You will need to Retreive Record with Given Record ID and Record Logical Name
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
Entity abc= service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet("colum1", "field2", "field3", "field4"));
Here is the link which explains all in Details
I have two entities BlogPost and user im not sure how the follow mechanism works I have searched on S.O but could not get an idea
What I think
I think follow is some sort of Get posts where userID = ?
but also it should be a continues process ie when user posts again it should automatically get the new post, until user unfollows.
I would like some suggestions on how to go about implementing and what i will need.
What i am trying to create
I want to create a service that subcribes to a user (like in the social networks such linkedIn, so a user can follow another user there by getting all the users new activities such as new posts (new uploads)
public void subscribeToUser(String id){
//follow a user by id
//im not sure the relationship i should create between the entities
// user and posts so that when one user creates a post
// another user can subscribe to the first user and can see all the posts and future posts of the user
}
}
I have entity "Work Order" for which I have defined many custom views. Work Orders can have records with statuses as "active ,cancelled, closed, inprogress, submitted" etc. My requirement is - currently logged in user who belongs to a specific team "sales representative" should be able to see all records on view.This can be done easily, but If current logged in user does not belongs to "sales representative" team, she should not be able to see "cancelled" records on view but all other record should be visible to her. How can I achieve this using custom filters if it is possible? Or by code changes?
It is possible to do this with custom code. Without questioning the "why" you'd like to do this (possibly it's sensitive information or something?), you can achieve it using a RetrieveMultiple plugin registered on the pre-operation event. Within this plugin one of the input parameters passed in is called "Query" and will have a QueryExpression. You can simply add a filter to this query in the plugin and the relevant rows will be filtered out. Something like this:
var query = (QueryExpression)context.InputParameters["Query"];
var condition= new ConditionExpression()
{
AttributeName = "statuscode",
Operator = ConditionOperator.NotIn,
Values = { 2, 3 } // Or whatever codes you want to filter!
};
query.Criteria.AddCondition(condition);
To check the current user you can grab the user id from the plugin context and retrieve the necessary info you would like to check.
Doesn't sound like this is possible with advanced find alright. You may be able to achieve it using security roles though. If you could assign cancelled work orders to a specific team, and then organise your security setup so that users who are not sales representatives can't see work orders from that specific team, then it might work. Unfortunately you would have to reassign the cancelled work orders which is not always an option.
Otherwise, you might have to go with a separate view for cancelled work orders, out of the box advanced find should allow you present a blank grid of you are not on the right team. But now obviously you are not presenting a whole view of the work orders.
In general I would go with the security option, and just make it work. Any other option is just a stop-gap. Users can always create custom views, so if you don't lock down access using security roles, the data is still accessible in indirect ways.
Through which file are new customers created and saved in Magento databases?
Which function is used?
Please provide me with full path locations and function names.
Also tell me about customer groups. From where and through which files/functions do customer groups get saved in Magento?
How are customers and customer groups related?
How can I "catch" customer IDs and customer group IDs from those files?
I find the file through which Magento saves New Customer-:
/magento/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
In the file CustomerController.php, there is a function saveAction() which saves a customer in Magento db.
I wanted to know how to catch Newly created customer's id(I guesss i.e. Entity Id in Customer_entity table for Magento db) from that CustomerController.php file.
I tried this but it won't work for me-"
$customer_data = Mage::getModel('customer/customer')->load($customer_id);
Anybody knows how to catch customer id while creation of new customer???
Try to search here:
Mage_Customer_AccountController->createPostAction
Well class name means
(root)/app/code/core/Mage/Customer/controllers/AccountControlller
Mage_Adminhtml_Customer_GroupController
Take a look at the AccountController.php at app/code/core/Mage/Customer/controllers, it will give you an idea how customer registration is processed.
Basically an instance of Mage_Customer_Model_Customer is created, proper data is assigned to it (collected from a post form on the registraton form or received via a webservice call) and the model is saved. The internal Magento mechanics work to put this data in proper db tables.
See also create function of the Mage_Customer_Model_Customer_Api class.
customer groups are created in Mage_Adminhtml_Customer_GroupController->saveAction(), the model being used is Mage_Customer_Model_Group
actually customer group is assigned from backend,by default general group is selected for customer group, if you want to get customer groups then you can use this code Mage::helper('customer')->getGroups()->toOptionArray();
Search for this file
/YourProject/app/code/core/Mage/Customer/controllers/AccountController.php
Search for this function name
public function createPostAction() //Magento saves New Customer
This above mentioned function is responsible for new customer registration.
print_r($this->getRequest()->getPost()); //get all the post data
print_r($session); //get all the session data