titan make unique vertex based on property key - unique

I want to create a vertexs that do not have duplicate property, e.g., name
I followed the page https://github.com/thinkaurelius/titan/wiki/Vertex-Centric-Indices
However, it does not work for me
gremlin>g.makeType().name('dom').unique(OUT).dataType(String.class).indexed(Vertex.class).makePropertyKey()
==>v[36028797018965714]
gremlin> u2 = g.addVertex([dom:'def.com'])
==>v[480020]
gremlin> u2 = g.addVertex([dom:'def.com'])
==>v[480024]
Can I just have one vertext created for the same dom property?
Thanks in advance

You need to define your type as unique(BOTH). You can read more about types here.
gremlin> g = TitanFactory.open('/tmp/titan')
==>titangraph[local:/tmp/titan]
gremlin> g.makeType().name('dom').unique(BOTH).dataType(String.class).indexed(Vertex.class).makePropertyKey()
==>v[36028797018963978]
gremlin> g.commit()
==>null
gremlin> u2 = g.addVertex([dom:'def.com'])
==>v[4]
gremlin> u2 = g.addVertex([dom:'def.com'])
The given value is already used as a property and the property key is defined as in-unique
Display stack trace? [yN] n
gremlin>

Related

Function modules to update table bsid (field: cession_kz)

For a certain program I need to update table bsid. The field cession_kz needs to be updated. I've looked for many function modules but none of them fit my needs. Does someone know a best practice to solve this problem?
BSID is a secondary index for BSEG customer items, so updating it directly will lead to database inconsistencies and any update must go via BSEG.
You can use a function module like FI_ITEMS_MASS_CHANGE. This FM updates BSEG by running a BDC for transaction FB02 (Change Document). When a relevant (customer) item is changed in BSEG, the corresponding BSID record is changed as well.
See example code below:
DATA: ls_bseg TYPE bseg,
lt_errdoc TYPE tpit_t_errdoc,
lt_fname TYPE tpit_t_fname,
lt_buztab TYPE tpit_t_buztab.
* Field name to be changed
APPEND 'CESSION_KZ' TO lt_fname.
* New field value
ls_bseg-cession_kz = 'AB'.
* Selection of items to be changed
* Only select customer items to avoid problems in batch input
SELECT bukrs belnr gjahr buzei koart umskz bschl mwart mwskz
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE lt_buztab
WHERE belnr = '1400000000' AND
bukrs = '1000' AND
koart = 'D'. "Customers
CALL FUNCTION 'FI_ITEMS_MASS_CHANGE'
EXPORTING
s_bseg = ls_bseg
IMPORTING
errtab = lt_errdoc[]
TABLES
it_buztab = lt_buztab
it_fldtab = lt_fname
EXCEPTIONS
bdc_errors = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Make sure you allow changes in maintenance view V_TBAER with transaction SM30 or through customizing:
Financial Accounting → Financial Accounting Global Settings → Document → Line Item → Document Change Rules, Line Item.
Note:
Pledging indicators should be defined for all company codes passed to the FM:
Financial Accounting → Accouts Receivable and Accounts Payable → Customer Account → Master Data → Preperation for creating master data → Define Accounts Receivable Pledging Indicator.
If not, the field will not be available for the batch input and the FM will result in an error.

Access UPDATE statement in query fails to actually update

The following tables exist:
Passerine_Survey_Observation
Species_Codes
I'm trying to set the common name in Passerine_Survey_Observation with that of Species_Codes:
UPDATE Passerine_Survey_Observation
INNER JOIN Species_Codes ON Passerine_Survey_Observation.SPEC_FK = Species_Codes.SPEC
SET Passerine_Survey_Observation.Species_Common_Name = Species_Codes.COMMONNAME;
It says an update will occur; however, nothing changes in Passerine_Survey_Observation.
Supposed update warning
If I do this an update does occur as expected:
SET Passerine_Survey_Observation.Species_Common_Name = 'test'
#Knox was onto something...
This behavior occurred because the target field (Passerine_Survey_Observation.Species_Common_Name) - in Design View - was a List Box (under the Properties > Lookup tab). Setting that to Display Control = Text Box resolved the problem. Oops.
Final code:
UPDATE Passerine_Survey_Observation
INNER JOIN Species_Codes ON Passerine_Survey_Observation.[SPEC_FK] = Species_Codes.[SPEC]
SET Passerine_Survey_Observation.Species_Common_Name = Species_Codes.[COMMONNAME]
WHERE Passerine_Survey_Observation.Species_Common_Name IS NULL;

Include nested entity details but don't group by then when grouping by other fields

I working with Database first C# MVC, EF6, LINQ and JSon to try and pass data to both Highcharts and Google Maps for some of my reporting.
If I could add an image I would show you the relevant portion of my model, but sadly I need more reputation to do that...
The portion of the Entity Model I'm concentrating on right now is based on a central Docket that contains a BuildingCode as part of a one-to-many relationship to a building with and address and further relationship to the buildings polygons (for mapping). Dockets are also classified by one or more DocketTypes and thus there is a many-to-many relationship between Dockets and DocketTypes, which is not directly exposed to through the EF.
As an example a Docket which represents an investigation, could be related to the theft of a mobile phone in building A located on Campus X, not only was the cellphone stolen but the assailant also assaulted the victim in order to steal the mobile phone. So there are 2 DocketTypes here 1. Theft of mobile phone and 2. assault. Note: this is fictitious and for illustration purposes only .
One of my fundamental reports requires that I count how many docketTypes affect each building and each campus in a given period. When I display this I also need to show what the DocketTypes are.
I have no end of nightmare trying to find a way to get this right, I keep running into circular reference errors and needing to use explicit conversions when trying to model the data with LINQ so that I can pass a single nested object through JSON to the client side where displaying will occur.
In the below code I am told I need an Explicit conversion:
Cannot implicitly convert type 'Campus_Investigator.ViewModels.DocketTypeViewModel' to 'System.Collections.Generic.IEnumerable<Campus_Investigator.ViewModels.DocketTypeViewModel>'. An explicit conversion exists (are you missing a cast?)
var currentDocketQuery = from d in db.Dockets
from dt in d.DocketTypes
from bp in d.BuildingDetail.BuildingPolygons
where d.OccurrenceStartDate >= datetime && d.BuildingDetail.CampusName == Campus
select new CampusBuildingDocketTypeViewModel()
{
BuildingCode = d.BuildingDetail.BuildingCode,
BuildingName = d.BuildingDetail.BuildingName,
//BuildingPolygons = d.BuildingDetail.BuildingPolygons,
DocketTypes = new DocketTypeViewModel()
{
Category = dt.Category,
SubCategory = dt.SubCategory,
ShortDescription = dt.ShortDescription
}
};
I appreciate any ideas on how I can explicitly convert this or is that a better method I can use and avoid the circular reference error?
You included some redundant part in your query (which performs some inner join). The from bp in d.BuildingDetail.BuildingPolygons is joined in but then is not shown in the result. So it totally does not make sense. There may be duplicated elements in the result due to that. The from dt in d.DocketTypes is wrong joined in, although you need it in the result but because the DocketTypes is output per d in db.Dockets, so it's just simply queried like this:
var currentDocketQuery = from d in db.Dockets
where d.OccurrenceStartDate >= datetime && d.BuildingDetail.CampusName == Campus
select new CampusBuildingDocketTypeViewModel()
{
BuildingCode = d.BuildingDetail.BuildingCode,
BuildingName = d.BuildingDetail.BuildingName,
//BuildingPolygons = d.BuildingDetail.BuildingPolygons,
DocketTypes = d.DocketTypes
};
In fact I can see the commented line //BuildingPolygons = d.BuildingDetail.BuildingPolygons, so if you want to include that, it should also work.
If the DocketTypes has different type of d.DocketTypes, then you need a simple projection like this:
var currentDocketQuery = from d in db.Dockets
where d.OccurrenceStartDate >= datetime && d.BuildingDetail.CampusName == Campus
select new CampusBuildingDocketTypeViewModel()
{
BuildingCode = d.BuildingDetail.BuildingCode,
BuildingName = d.BuildingDetail.BuildingName,
//BuildingPolygons = d.BuildingDetail.BuildingPolygons,
DocketTypes = d.DocketTypes.Select(e => new DocketTypeViewModel()
{
Category = e.Category,
SubCategory = e.SubCategory,
ShortDescription = e.ShortDescription
})
};
I managed to solve this one by using the below. The major hassle with this is the circular referencing that exists in the model. When JSON serializes these, everything falls apart so it takes a lot of transforming to make sure that I only extract what I need. In this case grouped campus and building data (below includes the polygons which where only half commented out in the above) and then the include the detail of the DocketTypes that occurred at each building.
var datetime = DateTime.Now.AddDays(-30);
var campusDocket = from d in db.Dockets
where d.OccurrenceStartDate >= datetime && d.BuildingDetail.CampusName == Campus
group d by new { d.BuildingDetail.CampusName, d.BuildingDetail.BuildingCode, d.BuildingDetail.BuildingName } into groupdata
select new CampusBuildingDocketTypeViewModel
{
BuildingCode = groupdata.Key.BuildingCode,
BuildingName = groupdata.Key.BuildingName,
CampusName = groupdata.Key.CampusName,
Count = groupdata.Count(),
BuildingPolygons = from bp in db.BuildingPolygons
where bp.BuildingCode == groupdata.Key.BuildingCode
select new BuildingPolygonViewModel
{
Accuracy = bp.Accuracy,
BuildingCode = bp.BuildingCode,
PolygonOrder = bp.PolygonOrder,
Latitude = bp.Latitude,
Longitude = bp.Longitude
},
DocketTypes = from doc in db.Dockets
from dt in doc.DocketTypes
where doc.OccurrenceStartDate >= datetime && doc.BuildingCode == groupdata.Key.BuildingCode
select new DocketTypeViewModel
{
Category = dt.Category,
SubCategory = dt.SubCategory,
ShortDescription = dt.ShortDescription
}
};
The Answer again is ViewModels. I'm finding ViewModels seem to solve a lot of problems...

Magento, i need define first product image as thumbnail

I had imported my old oscommerce site with 15000 produts for magento!
But unfortably, the thumbnails are dont defined automatically
http://imgur.com/cNdXd
i can do maually, but 15000 produts is a larg number and i need sped a big amout of time for do it
if anywone can give-me a mysql command to set the first produts image as Base Image, Small Image and Thumbnail will be awesome
thanks
Try update them via api:
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$products = $proxy->call($sessionId, 'product.list');
foreach ($products as $product) {
$images = $proxy->call($sessionId, 'product_media.list', $product['sku'])
$imageFilename = $images[0]['file'];
$proxy->call($sessionId, 'product_media.update', array(
$product['sku'],
$imageFilename,
array('types' => array('image', 'thumbnail')
));
}
Related documentation links:
http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product_attribute_media
http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product#catalog_product.list
Im having a problem with this SQL code i got somewhere which is supposed to set your first image as image, small image and thumbnail:
UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mg.entity_id = ev.entity_id
AND ev.attribute_code IN ('image', 'small_image', 'thumbnail')
AND mgv.position = 1;
Doesn't change any rows...
Also, my attribute_id's for image, small_image, thumbnail and media_gallery in Magento CE v1.6.2 are 106,109,493,703 using EMSupermarket template.
The following code also does nothing:
UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mg.entity_id = ev.entity_id
AND ev.attribute_id IN (106,109,493)
AND mgv.position = 1;
Anyone how to do this correctly with my id's?
What happened with my oscommerce product import was that the imported product images only end up under the field name media_image, but not image, small_image or thumbnail so i want to copy the media_image values over to the other 3, any ideas how to do this?
I had the same problem. I found this page and ran that SQL command, and also did not get any results. But I modified it to work for me. Here is what I did.
First of all, I changed line 7 from:
AND ev.attribute_code IN ('image', 'small_image', 'thumbnail')
to
AND ev.attribute_ID = '74'
the 74 is my unique attribute id for 'image'. You will have a different number here. You find it by looking it up in mySQL...
75 was for 'small_image' and 76 for 'thumbnail'.
So I ran this code 3 times, 1 for each of those attribute number. Each time I change line 7 ev.attribute_ID = '75' :
UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mg.entity_id = ev.entity_id
AND ev.attribute_ID = '76'
AND mgv.position = 1;

BOBJ SDK Add Group MemberOf Parent Group

All,
I add a group to be a child of the parent group but, it is not becoming a member of the parent group. I have to go in and set it manually.
Anyone know how this works?
I had to play with it and do a little research on the BOB Forum but I figured it out, though its non-intuitive.
I'm going to assume you know how to get the parent group IUserGroup object.
// get the plugin manager
IPluginMgr pluginMgr = store.getPluginMgr();
// Retrieve the User plugin.
IPluginInfo groupPlugin = pluginMgr.getPluginInfo("CrystalEnterprise.UserGroup");
// Create a new InfoObjects collection.
IInfoObjects newInfoObjects = store.newInfoObjectCollection();
// Add the User plugin to the collection.
newInfoObjects.add (groupPlugin);
// Retrieve the newly created user object.
IUserGroup newUserGroup = (IUserGroup)newInfoObjects.get(0);
// build the new group
String newGroupName = "My Test Group";
newUserGroup.setTitle(newGroupName);
newUserGroup.setDescription("Just for sample test code");
store.commit(newInfoObjects);
// now that things commited associate the parent group
if(parentGroup != null)
{
parentGroup.getSubGroups().add(new Integer(newUserGroup.getID()));
store.commit(parGroupObjs);
}
The big stumper is that you you would expect to just use the setParentID() method. Word of warning this this was only tested under BO XI R2, not R3, so it may not be 100% correct for the current version.