Subversion Repositories SmartDukaan

Rev

Rev 2078 | Rev 3127 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2078 Rev 2095
Line 1... Line 1...
1
package in.shop2020.creation.controllers;
1
package in.shop2020.creation.controllers;
2
 
2
 
-
 
3
import java.util.ArrayList;
-
 
4
import java.util.Calendar;
-
 
5
import java.util.Date;
-
 
6
import java.util.List;
-
 
7
 
3
import in.shop2020.content.security.UserManager;
8
import in.shop2020.content.security.UserManager;
4
import in.shop2020.creation.util.ContentValidator;
9
import in.shop2020.creation.util.ContentValidator;
5
import in.shop2020.metamodel.core.Entity;
10
import in.shop2020.metamodel.core.Entity;
6
import in.shop2020.metamodel.core.EntityState;
11
import in.shop2020.metamodel.core.EntityState;
-
 
12
import in.shop2020.metamodel.core.EntityStatus;
7
import in.shop2020.metamodel.util.CreationUtils;
13
import in.shop2020.metamodel.util.CreationUtils;
8
import in.shop2020.thrift.clients.CatalogServiceClient;
14
import in.shop2020.thrift.clients.CatalogServiceClient;
9
 
15
 
10
import org.apache.struts2.convention.annotation.InterceptorRef;
16
import org.apache.struts2.convention.annotation.InterceptorRef;
11
import org.apache.struts2.convention.annotation.InterceptorRefs;
17
import org.apache.struts2.convention.annotation.InterceptorRefs;
Line 54... Line 60...
54
				return "success";
60
				return "success";
55
			}
61
			}
56
			
62
			
57
			if(action.equalsIgnoreCase("assign")){
63
			if(action.equalsIgnoreCase("assign")){
58
				if(this.reqparams.get("username") !=null){
64
				if(this.reqparams.get("username") !=null){
59
					if(!UserManager.getUserManager().canAssign(getUsername(), entityId)){
65
				    if(!UserManager.getUserManager().canAssign(getUsername(), entityId)){
60
						addActionError("You do not have rights to assign an entity");
66
						addActionError("You do not have rights to assign an entity");
61
						return "success";	
67
						return "success";	
62
					}
68
					}
63
					String assignTo = this.reqparams.get("username")[0];
69
					String assignTo = this.reqparams.get("username")[0];
64
					System.out.println("User name is " + assignTo);
70
					System.out.println("User name is " + assignTo);
65
					try {
71
					try {
66
						EntityState state = CreationUtils.getEntityState(entityId);
72
						EntityState state = CreationUtils.getEntityState(entityId);
-
 
73
						if(state.getStatus() == EntityStatus.READY){
-
 
74
						    Calendar cl = Calendar.getInstance();
-
 
75
		                    if(cl.get(Calendar.HOUR_OF_DAY) > 14 && cl.get(Calendar.HOUR_OF_DAY) < 16){
-
 
76
		                        addActionError("Sorry.... This is not right time to assign this entity. Please visit after 4 PM.");
-
 
77
		                        return "success";   
-
 
78
		                    }
-
 
79
						    List<Long> inconsistentEntities = CreationUtils.getInconsistentEntities();
-
 
80
						    if(inconsistentEntities == null){
-
 
81
						        inconsistentEntities = new ArrayList<Long>();
-
 
82
						    }
-
 
83
						    inconsistentEntities.add(state.getID());
-
 
84
						    CreationUtils.storeInconsistentEntities(inconsistentEntities);
-
 
85
						}
67
						state.assignEntity(this.getUsername(), assignTo);
86
						state.assignEntity(this.getUsername(), assignTo);
68
						CreationUtils.updateEntityState(state);
87
						CreationUtils.updateEntityState(state);
69
					} catch (Exception e) {
88
					} catch (Exception e) {
70
						e.printStackTrace();
89
						e.printStackTrace();
71
					}
90
					}
Line 85... Line 104...
85
				    
104
				    
86
					CatalogServiceClient csc = new CatalogServiceClient();
105
					CatalogServiceClient csc = new CatalogServiceClient();
87
					in.shop2020.model.v1.catalog.InventoryService.Client iclient = csc.getClient();
106
					in.shop2020.model.v1.catalog.InventoryService.Client iclient = csc.getClient();
88
					iclient.markItemAsContentComplete(entityId, state.getCategoryID(), state.getBrand(), state.getModelName(), state.getModelNumber());	
107
					iclient.markItemAsContentComplete(entityId, state.getCategoryID(), state.getBrand(), state.getModelName(), state.getModelNumber());	
89
					
108
					
-
 
109
                    List<Long> inconsistentEntities = CreationUtils.getInconsistentEntities();
-
 
110
                    if(inconsistentEntities != null){
-
 
111
                        inconsistentEntities.remove(state.getID());
-
 
112
                        CreationUtils.storeInconsistentEntities(inconsistentEntities);
-
 
113
                    }
90
					
114
					
91
					state.readyEntity(getUsername());
115
					state.readyEntity(getUsername());
92
					CreationUtils.updateEntityState(state);
116
					CreationUtils.updateEntityState(state);
93
					addActionMessage("Entity marked as ready successfully");
117
					addActionMessage("Entity marked as ready successfully");
94
				} catch (Exception e) {
118
				} catch (Exception e) {