Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Array #101

Closed
vishaldeshai opened this issue Aug 9, 2017 · 8 comments
Closed

Parsing Array #101

vishaldeshai opened this issue Aug 9, 2017 · 8 comments

Comments

@vishaldeshai
Copy link

Hello,

i am parsing following:
reason: 'Unacceptable type of value for ordered to-many relationship: property = "visitStatusList"; desired type = NSOrderedSet; given type = __NSArrayM; value = (
"<VisitStatus: 0x7c64fec0> (entity: VisitStatus; id: 0x7c64ff20 x-coredata:///VisitStatus/tB60DAD31-2D22-4158-B2B3-4D27C5F75A763 ; data: {\n conclusion = "";\n createdBy = 18;\n createdByName = "Manager Raina";\n createdTime = "Jul 11, 2017 11:29:05 AM";\n iD = 729;\n interactionTime = "Jul 11, 2017 11:28:00 AM";\n interactionTypeID = 1;\n interactionWith = 0;\n interactionWithName = "";\n nextActionID = 1;\n nextActionTime = "Jul 12, 2017 4:30:00 AM";\n plannVisit = nil;\n visitID = 1360;\n visitOutcomeID = 1;\n visitTypeID = 1;\n})",
"<VisitStatus: 0x7c650cd0> (entity: VisitStatus; id: 0x7c005f20 x-coredata:///VisitStatus/tB60DAD31-2D22-4158-B2B3-4D27C5F75A764 ; data: {\n conclusion = "";\n createdBy = 19;\n createdByName = "Admin Lee";\n createdTime = "Aug 1, 2017 12:42:25 PM";\n iD = 739;\n interactionTime = "Aug 1, 2017 12:42:00 PM";\n interactionTypeID = 1;\n interactionWith = 0;\n interactionWithName = "";\n nextActionID = 1;\n nextActionTime = "Aug 1, 2017 2:30:00 PM";\n plannVisit = nil;\n visitID = 1360;\n visitOutcomeID = 1;\n visitTypeID = 1;\n})"
).'

thanks in advance.....

@dimazen
Copy link
Contributor

dimazen commented Aug 9, 2017

Hello, @vishaldeshai.
Can you please show declaration of the class that holds visitStatusList relationship? Looks like an internal (i.e. library's) error during translation from the parsed Array to the Ordered Set that is expected by the CD model.

@vishaldeshai
Copy link
Author

vishaldeshai commented Aug 9, 2017

Below are my stucture:

FEMMapping *mapping = [[FEMMapping alloc]initWithEntityName:[PlannVisit entityName]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"iD" andKeyPath:@"ID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"seriesPostfix" andKeyPath:@"SeriesPostfix"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"customerID" andKeyPath:@"CustomerID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"tempCustomerID" andKeyPath:@"TempCustomerID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"contactID" andKeyPath:@"ContactID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"originalNextActionID" andKeyPath:@"OriginalNextActionID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"nextActionID" andKeyPath:@"NextActionID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"visitTypeID" andKeyPath:@"VisitTypeID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"visitStatusID" andKeyPath:@"VisitStatusID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"addressMasterID" andKeyPath:@"AddressMasterID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"originalAssignee" andKeyPath:@"OriginalAssignee"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"reAssigned" andKeyPath:@"ReAssigned"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"assignedBy" andKeyPath:@"AssignedBy"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"companyID" andKeyPath:@"CompanyID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"createdBy" andKeyPath:@"CreatedBy"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"lastModifiedBy" andKeyPath:@"LastModifiedBy"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"isActive" andKeyPath:@"IsActive"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"approvedBy" andKeyPath:@"ApprovedBy"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"approvedTo" andKeyPath:@"ApprovedTo"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"filterType" andKeyPath:@"FilterType"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"sortType" andKeyPath:@"SortType"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"filterUser" andKeyPath:@"FilterUser"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"filterProduct" andKeyPath:@"FilterProduct"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"filterCategoryID" andKeyPath:@"FilterCategoryID"]];
[mapping addAttribute:[PlannVisit intAttributeFor:@"beatPlanID" andKeyPath:@"BeatPlanID"]];
[mapping addAttributesFromDictionary:@{@"seriesPrefix": @"SeriesPrefix",@"customerName":@"CustomerName",@"contactName":@"ContactName",@"contactMobileNo":@"ContactMobileNo",@"originalNextActionTime":@"OriginalNextActionTime",@"nextActionTime":@"NextActionTime",@"conclusion":@"Conclusion",@"assignedTime":@"AssignedTime",@"ressigneeName":@"RessigneeName",@"createdByName":@"CreatedByName",@"createdTime":@"CreatedTime",@"lastModifiedTime":@"LastModifiedTime"}];
[mapping addRelationshipMapping:[_ProductList defaultMapping] forProperty:@"productList" keyPath:@"ProductList"];
[mapping addToManyRelationshipMapping:[_VisitStatus defaultMapping] forProperty:@"visitStatusList" keyPath:@"VisitStatusList"];
// [mapping addRelationshipMapping:[_CustomerDetails defaultMapping] forProperty:@"customerDetails" keyPath:@"CustomerDetails"];
mapping.primaryKey = @"iD";
return mapping;

ProductList is a Dictionary so it working fine but VisitStatusList is an array so that is not working....

@vishaldeshai
Copy link
Author

// VisitStatusList Mapping

+(FEMMapping *)defaultMapping{
FEMMapping *mapping = [[FEMMapping alloc]initWithEntityName:[VisitStatus entityName]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"iD" andKeyPath:@"ID"]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"visitID" andKeyPath:@"VisitID"]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"interactionTypeID" andKeyPath:@"InteractionTypeID"]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"interactionWith" andKeyPath:@"InteractionWith"]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"visitOutcomeID" andKeyPath:@"VisitOutcomeID"]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"visitTypeID" andKeyPath:@"VisitTypeID"]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"nextActionID" andKeyPath:@"NextActionID"]];
[mapping addAttribute:[VisitStatus intAttributeFor:@"createdBy" andKeyPath:@"CreatedBy"]];
[mapping addAttributesFromDictionary:@{@"interactionWithName": @"InteractionWithName",@"interactionTime":@"InteractionTime",@"nextActionTime":@"NextActionTime",@"conclusion":@"Conclusion",@"createdByName":@"CreatedByName",@"createdTime":@"CreatedTime"}];
mapping.primaryKey = @"iD";
return mapping;
}

@dimazen
Copy link
Contributor

dimazen commented Aug 9, 2017

Can you also share part of the JSON (only the one that shows PlannVisit and a VisitStatus) as well as how do you declare that relationship on the CoreData object?
i.e.

@interface PlannVisit: NSManagedObject

@property (nonatomic, strong) NSOrderedSet *visitStatusList;  // do you have a generic, or it is a swift version?

@end

@vishaldeshai
Copy link
Author

{
"ID": 1430,
"SeriesPrefix": "",
"SeriesPostfix": 222,
"CustomerID": 414,
"TempCustomerID": 0,
"CustomerName": "Arc Pvt Ltd",
"ContactID": 0,
"ContactName": "",
"ContactMobileNo": "",
"OriginalNextActionID": 2,
"OriginalNextActionTime": "Jul 26, 2017 6:07:00 AM",
"NextActionID": 1,
"NextActionTime": "Aug 1, 2017 2:30:00 PM",
"VisitTypeID": 1,
"VisitStatusID": 1,
"AddressMasterID": 731,
"OriginalAssignee": 18,
"AssignedTime": "Jul 26, 2017 4:59:48 AM",
"ReAssigned": 18,
"RessigneeName": "Manager Raina",
"AssignedBy": 19,
"CompanyID": 1,
"CreatedBy": 19,
"CreatedByName": "Admin Lee",
"CreatedTime": "Jul 26, 2017 4:59:48 AM",
"LastModifiedBy": 19,
"LastModifiedTime": "Aug 1, 2017 12:41:31 PM",
"IsActive": 1,
"VisitStatusList": [
{
"ID": 736,
"VisitID": 1430,
"InteractionTypeID": 1,
"InteractionWith": 0,
"InteractionWithName": "",
"InteractionTime": "Jul 28, 2017 9:20:00 AM",
"VisitOutcomeID": 1,
"VisitTypeID": 1,
"NextActionID": 1,
"NextActionTime": "Jul 29, 2017 4:30:00 AM",
"Conclusion": "",
"CreatedBy": 19,
"CreatedByName": "Admin Lee",
"CreatedTime": "Jul 28, 2017 9:20:49 AM"
},
{
"ID": 738,
"VisitID": 1430,
"InteractionTypeID": 1,
"InteractionWith": 0,
"InteractionWithName": "",
"InteractionTime": "Aug 1, 2017 12:40:00 PM",
"VisitOutcomeID": 1,
"VisitTypeID": 1,
"NextActionID": 1,
"NextActionTime": "Aug 1, 2017 2:30:00 PM",
"Conclusion": "",
"CreatedBy": 19,
"CreatedByName": "Admin Lee",
"CreatedTime": "Aug 1, 2017 12:41:31 PM"
}
],
"VisitCheckInCheckOutList": [
{
"ID": 482,
"VisitDate": "Aug 1, 2017 12:00:00 AM",
"VisitID": 1430,
"CompanyID": 1,
"CheckInTime": "Aug 1, 2017 12:40:40 PM",
"Lattitude": "23.0127686",
"Longitude": "72.5113895",
"StatusID": 2,
"CheckInCheckOutStatusID": 1,
"CreatedBy": 19,
"CreatedByName": "Admin",
"CreatedTime": "Aug 1, 2017 12:40:40 PM",
"ApprovedBy": 19,
"ApprovedTo": 19,
"LastModifiedBy": 19,
"CustomerID": 0,
"AddressMasterID": 0
},
{
"ID": 476,
"VisitDate": "Jul 28, 2017 12:00:00 AM",
"VisitID": 1430,
"CompanyID": 1,
"CheckInTime": "Jul 28, 2017 9:30:03 AM",
"Lattitude": "23.0127586",
"Longitude": "72.5114011",
"StatusID": 2,
"CheckInCheckOutStatusID": 1,
"CreatedBy": 18,
"CreatedByName": "Manager",
"CreatedTime": "Jul 28, 2017 9:30:03 AM",
"ApprovedBy": 18,
"ApprovedTo": 18,
"LastModifiedBy": 18,
"CustomerID": 0,
"AddressMasterID": 0
},
{
"ID": 475,
"VisitDate": "Jul 28, 2017 12:00:00 AM",
"VisitID": 1430,
"CompanyID": 1,
"CheckInTime": "Jul 28, 2017 9:18:21 AM",
"CheckOutTime": "Jul 28, 2017 10:06:08 AM",
"Lattitude": "23.0127686",
"Longitude": "72.5113895",
"StatusID": 2,
"CheckInCheckOutStatusID": 1,
"CreatedBy": 19,
"CreatedByName": "Admin",
"CreatedTime": "Jul 28, 2017 9:18:21 AM",
"ApprovedBy": 19,
"ApprovedTo": 19,
"LastModifiedBy": 19,
"CustomerID": 0,
"AddressMasterID": 0
}
],
"CustomerDetails": {
"ID": 1,
"Name": "Arc Pvt Ltd",
"MobileNo": "8689886898",
"LandlineNo": "",
"EmailID": "",
"OwnerID": 19,
"CompanyTypeID": 1,
"CreatedBy": 19,
"KeyCustomer": false,
"CreatedTime": "Jul 14, 2017 10:49:42 AM",
"Type": "U",
"Transactional": false,
"KeyCustomerVendor": false,
"Description": "Abc",
"IsActive": 0,
"CompanyID": 1,
"AddressList": [
{
"AddressMasterID": 731,
"Country": "India",
"State": "Gujarat",
"City": "Ahmedabad",
"AddressLine1": "A122, Anandnagar Road",
"AddressLine2": "Prahlad Nagar",
"Pincode": "380015",
"Lattitude": "23.012723",
"Longitude": "72.5112855",
"CreatedTime": "Dec 15, 2016 12:00:49 PM",
"Type": 1,
"Verified": true
}
],
"TaxType": "VAT",
"TaggedTo": 18,
"TaggedUserName": "Manager Raina",
"TaggedRoleID": 7
},
"ApprovedBy": 0,
"ApprovedTo": 0,
"FilterType": 0,
"SortType": 0,
"FilterUser": 0,
"FilterProduct": 0,
"FilterCategoryID": 0,
"BeatPlanID": 0
}

@dimazen
Copy link
Contributor

dimazen commented Aug 9, 2017

Thanks a lot! I'll take a look at it today in the evening. Fix should be rolled out soon (either today's evening or tomorrow)

@vishaldeshai
Copy link
Author

screen shot 2017-08-09 at 4 04 32 pm
screen shot 2017-08-09 at 4 04 47 pm

Please also look at my relationship defined with entity.

@vishaldeshai
Copy link
Author

vishaldeshai commented Aug 9, 2017

Sorry i have issue with relationship defined
two things we have to take care like 1) NSOrderSet and 2) NSSet
now resolved......
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants