//
//  RecordViewDef.h
//  EAMMobile
//
//  Created by Weikang Ding on 3/14/11.
//  Copyright 2011 Infor. All rights reserved.
//

//This is an abstract class and its child class defines all business logic for a record view

#import <Foundation/Foundation.h>
#import "RecordData.h"
#import "LOVData.h"
#import "PickerData.h"
#import "EAMField.h"
#import "ScreenDesigner.h"
#import "PermissionController.h"
#import "EAMListDesigner.h"
#import "LOVGridWebService.h"
/*
@protocol RecordDataControllerDelegate

- (void)recordDataReady; //:(RecordData *)data;
- (void)recordDataFailed:(NSString *)errorMsg;
- (void)recordDataUploaded: (NSString *)message;

@end
*/

@interface RecordDataController : NSObject {
@protected
	NSMutableDictionary *_recordViewFields;
	NSArray *_recordViewLayout;
}

@property (nonatomic, strong) RecordData *recordValue;
@property (unsafe_unretained, nonatomic,readonly) NSMutableDictionary   *recordViewFields;
@property (unsafe_unretained, nonatomic,readonly) NSArray               *recordViewLayout;
@property (unsafe_unretained, nonatomic,readonly) NSMutableDictionary   *recordViewData;
@property (unsafe_unretained, nonatomic,readonly) NSMutableDictionary   *recordViewChildListViewData;
@property (nonatomic, strong) NSMutableArray *recordViewComments;
@property (nonatomic, strong) NSMutableArray *recordViewDocuments;
@property (nonatomic,assign) BOOL recordUpdated;
@property (nonatomic, strong)   WebQuery    *requestHandler;
@property (nonatomic, strong)   LOVGridWebService    *LOVRequestHandler;
@property (nonatomic, strong)   NSString    *currentLOVGridWSField;
@property (nonatomic, strong)   NSString    *requestFieldName;
//-- Screen Config Change Start
@property (nonatomic, strong)   NSString    *screenName;
@property (nonatomic, strong)   NSString    *childListScreenName;
@property (nonatomic, strong)   NSString    *systemScreenName;
@property (nonatomic, strong)   ScreenDesigner  *screenDesigner;
@property (nonatomic, strong)   NSString    *functionType;
@property (nonatomic, weak)               id    delegate;
@property (nonatomic        ) BOOL      commentEnabled;   //Control if the comment section is editable
@property (nonatomic        ) BOOL      documentEnabled;  //Control if the documment section is editable
@property (nonatomic        ) BOOL      locationEnabled;  //Control if the location button is editable

//-- Screen Config Change End
//@property (nonatomic,assign) id<RecordDataControllerDelegate> delegate;

- (LOVData *)getLOVDataSource:(NSString *)lovName;
- (PickerData *)getPickerDataSource:(NSString *)fieldName;
- (void)updateFieldValue:(NSString *)fieldName withValues:(NSArray *)fieldValues;

- (void)updateFieldDefinition:(NSString *)fieldName isRequired:(BOOL)required;
- (void)updateFieldDefinition:(NSString *)fieldName isReadOnly:(BOOL)readonly;
- (void)updateFieldDefinition:(NSString *)fieldName withConnectionType:(FieldConnectionType)connectionType;
- (void)updateFieldLabel:(NSString *)fieldName withString:(NSString *)newLabel;
- (void)lOVGridGetData:(NSString *)fieldName;
-(void)lOVGridWebServiceDone:(BOOL)success head:(NSArray *)head data:(NSArray *)data moreRecord:(BOOL)moreRecord error:(NSString *)error;

- (void)getModel:(NSString *)modelName withParameters:(WebQueryParameters *)parameters;
- (void)addModel:(id)model;
- (void)updateModel:(id)model;
- (void)removeModel:(id)model;
- (void)rollbackModel:(id)model;
- (void)getGrid:(NSString *)grid 
   withFunction: (NSString *)function 
       withType: (GridQueryType)gridQueryType 
withNumberofRows:(int)rows 
withCurrentPosition:(int)currentPosition 
 withParameters:(WebQueryParameters *)parameters
withDataSpyId:(NSString *)dataSpyId;
- (void)runRequest:(NSString *)request withParameters:(WebQueryParameters *)parameters forField:(NSString *)field;

- (void)requestSuccessWithData:(NSArray *)data withEntity:(NSString *)entityName withType:(WebQueryRequestType)type forField:(NSString *)requestFieldName;
- (void)requestSuccessWithModels:(NSArray *)models withType:(WebQueryRequestType)type withModel:(NSString *)modelName;
- (void)requestSuccessWithGridData:(GridData *)gridData withType:(WebQueryRequestType )type withGrid:(NSString *)gridName;
- (void)requestFailed:(NSString *)fault withEntity:(NSString *)entityName forField:(NSString *)requestFieldName;

- (BOOL)canInsert:(NSString **)errorMessage;
- (BOOL)canUpdate:(NSString **)errorMessage;
- (BOOL)canDelete:(NSString **)errorMessage;
- (void)assignDefaultValues;
- (BOOL)validateInputForRequiredFields;

//-- Screen Config Change Start
- (void)getScreenConfig;
- (void)screenConfigParseCompleted;
- (void)setSectionHidden :(NSString *) show andSectionName:(NSString *)sectionName;
- (void)updateFieldDefinition:(NSString *)fieldName isHidden:(BOOL)isHidden;
-(void) setScreenReadOnly;
//-- Screen Config Change End

@end
