aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.openecomp.sdc.be.model.operations.impl;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringJoiner;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.graph.GraphElementFactory;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.IComplexDefaultValue;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.operations.api.DerivedFromOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.model.tosca.constraints.ConstraintType;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterOrEqualConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.LessThanConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.MinLengthConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.openecomp.sdc.be.resources.data.PropertyData;
import org.openecomp.sdc.be.resources.data.PropertyValueData;
import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
import org.openecomp.sdc.be.resources.data.UniqueIdData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.thinkaurelius.titan.core.TitanVertex;

import fj.data.Either;

@Component("property-operation")
public class PropertyOperation extends AbstractOperation implements IPropertyOperation {

	private TitanGenericDao titanGenericDao;
	private DerivedFromOperation derivedFromOperation;
	
	public static void main(String[] args) {

		List<Pattern> buildFunctionPatterns = buildFunctionPatterns();

		for (Pattern pattern : buildFunctionPatterns) {

			String[] strs = { "str_replace", "{ str_replace:", " {str_replace:", " {   str_replace:", "{str_replace:" };
			for (String str : strs) {
				Matcher m = pattern.matcher(str);
				System.out.println(pattern.pattern() + " " + str + " " + m.find());
			}
		}

	}

	public PropertyOperation(TitanGenericDao titanGenericDao, DerivedFromOperation derivedFromOperation) {
		this.titanGenericDao = titanGenericDao;
		this.derivedFromOperation = derivedFromOperation;
	}

	private static Logger log = LoggerFactory.getLogger(PropertyOperation.class.getName());

	private static List<Pattern> functionPatterns = null;

	static {

		functionPatterns = buildFunctionPatterns();
	}

	/**
	 * The value of functions is in a json format. Build pattern for each function name
	 * 
	 * { str_replace: .... } {str_replace: .... } {str_replace: .... } { str_replace: .... }
	 * 
	 * @return
	 */
	private static List<Pattern> buildFunctionPatterns() {

		List<Pattern> functionPatterns = new ArrayList<>();

		String[] functions = { "get_input", "get_property" };

		for (String function : functions) {
			Pattern pattern = Pattern.compile("^[ ]*\\{[ ]*" + function + ":");
			functionPatterns.add(pattern);
		}

		return functionPatterns;
	}

	public PropertyDefinition convertPropertyDataToPropertyDefinition(PropertyData propertyDataResult, String propertyName, String resourceId) {
		log.debug("The object returned after create property is {}", propertyDataResult);

		PropertyDefinition propertyDefResult = new PropertyDefinition(propertyDataResult.getPropertyDataDefinition());
		propertyDefResult.setConstraints(convertConstraints(propertyDataResult.getConstraints()));
		propertyDefResult.setName(propertyName);
//		propertyDefResult.setParentUniqueId(resourceId);

		return propertyDefResult;
	}

	public static class PropertyConstraintSerialiser implements JsonSerializer<PropertyConstraint> {

		@Override
		public JsonElement serialize(PropertyConstraint src, Type typeOfSrc, JsonSerializationContext context) {
			JsonParser parser = new JsonParser();
			JsonObject result = new JsonObject();
			JsonArray jsonArray = new JsonArray();
			if (src instanceof InRangeConstraint) {
				InRangeConstraint rangeConstraint = (InRangeConstraint) src;
				jsonArray.add(parser.parse(rangeConstraint.getRangeMinValue()));
				jsonArray.add(parser.parse(rangeConstraint.getRangeMaxValue()));
				result.add("inRange", jsonArray);
			} else if (src instanceof GreaterThanConstraint) {
				GreaterThanConstraint greaterThanConstraint = (GreaterThanConstraint) src;
				jsonArray.add(parser.parse(greaterThanConstraint.getGreaterThan()));
				result.add("greaterThan", jsonArray);
			} else if (src instanceof LessOrEqualConstraint) {
				LessOrEqualConstraint lessOrEqualConstraint = (LessOrEqualConstraint) src;
				jsonArray.add(parser.parse(lessOrEqualConstraint.getLessOrEqual()));
				result.add("lessOrEqual", jsonArray);
			} else {
				log.warn("PropertyConstraint {} is not supported. Ignored.", src.getClass().getName());
			}

			return result;
		}

	}

	public static class PropertyConstraintDeserialiser implements JsonDeserializer<PropertyConstraint> {

		@Override
		public PropertyConstraint deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {

			PropertyConstraint propertyConstraint = null;

			Set<Entry<String, JsonElement>> set = json.getAsJsonObject().entrySet();

			if (set.size() == 1) {
				Entry<String, JsonElement> element = set.iterator().next();
				String key = element.getKey();
				JsonElement value = element.getValue();

				ConstraintType constraintType = ConstraintType.getByType(key);
				if (constraintType == null) {
					log.warn("ConstraintType was not found for constraint name:{}", key);
				} else {
					switch (constraintType) {
					case IN_RANGE:

						if (value != null) {
							if (value instanceof JsonArray) {
								JsonArray rangeArray = (JsonArray) value;
								if (rangeArray.size() != 2) {
									log.error("The range constraint content is invalid. value = {}", value);
								} else {
									InRangeConstraint rangeConstraint = new InRangeConstraint();
									String minValue = rangeArray.get(0).getAsString();
									String maxValue = rangeArray.get(1).getAsString();
									rangeConstraint.setRangeMinValue(minValue);
									rangeConstraint.setRangeMaxValue(maxValue);
									propertyConstraint = rangeConstraint;
								}
							}

						} else {
							log.warn("The value of GreaterThanConstraint is null");
						}
						break;
					case GREATER_THAN:
						if (value != null) {
							String asString = value.getAsString();
							log.debug("Before adding value to GreaterThanConstraint object. value = {}", asString);
							propertyConstraint = new GreaterThanConstraint(asString);
							break;
						} else {
							log.warn("The value of GreaterThanConstraint is null");
						}
						break;

					case LESS_THAN:
						if (value != null) {
							String asString = value.getAsString();
							log.debug("Before adding value to LessThanConstraint object. value = {}", asString);
							propertyConstraint = new LessThanConstraint(asString);
							break;
						} else {
							log.warn("The value of LessThanConstraint is null");
						}
						break;
					case GREATER_OR_EQUAL:
						if (value != null) {
							String asString = value.getAsString();
							log.debug("Before adding value to GreaterThanConstraint object. value = {}", asString);
							propertyConstraint = new GreaterOrEqualConstraint(asString);
							break;
						} else {
							log.warn("The value of GreaterOrEqualConstraint is null");
						}
						break;
					case LESS_OR_EQUAL:

						if (value != null) {
							String asString = value.getAsString();
							log.debug("Before adding value to LessOrEqualConstraint object. value = {}", asString);
							propertyConstraint = new LessOrEqualConstraint(asString);
						} else {
							log.warn("The value of GreaterThanConstraint is null");
						}
						break;

					case VALID_VALUES:

						if (value != null) {
							if (value instanceof JsonArray) {
								JsonArray rangeArray = (JsonArray) value;
								if (rangeArray.size() == 0) {
									log.error("The valid values constraint content is invalid. value = {}", value);
								} else {
									ValidValuesConstraint vvConstraint = new ValidValuesConstraint();
									List<String> validValues = new ArrayList<String>();
									for (JsonElement jsonElement : rangeArray) {
										String item = jsonElement.getAsString();
										validValues.add(item);
									}
									vvConstraint.setValidValues(validValues);
									propertyConstraint = vvConstraint;
								}
							}

						} else {
							log.warn("The value of ValidValuesConstraint is null");
						}
						break;

					case MIN_LENGTH:
						if (value != null) {
							int asInt = value.getAsInt();
							log.debug("Before adding value to Min Length object. value = {}", asInt);
							propertyConstraint = new MinLengthConstraint(asInt);
							break;
						} else {
							log.warn("The value of MinLengthConstraint is null");
						}
						break;
					default:
						log.warn("Key {} is not supported. Ignored.", key);
					}
				}
			}

			return propertyConstraint;
		}

	}

	public TitanOperationStatus addPropertiesToGraph(Map<String, PropertyDefinition> properties, String resourceId, Map<String, DataTypeDefinition> dataTypes) {

		ResourceMetadataData resourceData = new ResourceMetadataData();
		resourceData.getMetadataDataDefinition().setUniqueId(resourceId);

		if (properties != null) {
			for (Entry<String, PropertyDefinition> entry : properties.entrySet()) {

				String propertyName = entry.getKey();
				PropertyDefinition propertyDefinition = entry.getValue();

				StorageOperationStatus validateAndUpdateProperty = validateAndUpdateProperty(propertyDefinition, dataTypes);
				if (validateAndUpdateProperty != StorageOperationStatus.OK) {
					log.error("Property {} is invalid. Status is {}", propertyDefinition, validateAndUpdateProperty);
					return TitanOperationStatus.ILLEGAL_ARGUMENT;
				}

				Either<PropertyData, TitanOperationStatus> addPropertyToGraph = addPropertyToGraph(propertyName, propertyDefinition, resourceId);

				if (addPropertyToGraph.isRight()) {
					return addPropertyToGraph.right().value();
				}
			}
		}

		return TitanOperationStatus.OK;

	}

	public TitanOperationStatus addPropertiesToGraph(TitanVertex metadataVertex, Map<String, PropertyDefinition> properties, Map<String, DataTypeDefinition> dataTypes, String resourceId) {

		if (properties != null) {
			for (Entry<String, PropertyDefinition> entry : properties.entrySet()) {

				String propertyName = entry.getKey();
				PropertyDefinition propertyDefinition = entry.getValue();

				StorageOperationStatus validateAndUpdateProperty = validateAndUpdateProperty(propertyDefinition, dataTypes);
				if (validateAndUpdateProperty != StorageOperationStatus.OK) {
					log.error("Property {} is invalid. Status is {}", propertyDefinition, validateAndUpdateProperty);
					return TitanOperationStatus.ILLEGAL_ARGUMENT;
				}

				TitanOperationStatus addPropertyToGraph = addPropertyToGraphByVertex(metadataVertex, propertyName, propertyDefinition, resourceId);

				if (!addPropertyToGraph.equals(TitanOperationStatus.OK)) {
					return addPropertyToGraph;
				}
			}
		}

		return TitanOperationStatus.OK;

	}

	public Either<PropertyData, StorageOperationStatus> addProperty(String propertyName, PropertyDefinition propertyDefinition, String resourceId) {

		Either<PropertyData, TitanOperationStatus> either = addPropertyToGraph(propertyName, propertyDefinition, resourceId);
		if (either.isRight()) {
			StorageOperationStatus storageStatus = DaoStatusConverter.convertTitanStatusToStorageStatus(either.right().value());
			return Either.right(storageStatus);
		}
		return Either.left(either.left().value());
	}

	/**
	 * @param propertyDefinition
	 * @return
	 */
	@Override
	public StorageOperationStatus validateAndUpdateProperty(IComplexDefaultValue propertyDefinition, Map<String, DataTypeDefinition> dataTypes) {

		log.trace("Going to validate property type and value. {}", propertyDefinition);

		String propertyType = propertyDefinition.getType();
		String value = propertyDefinition.getDefaultValue();

		ToscaPropertyType type = getType(propertyType);

		if (type == null) {

			DataTypeDefinition dataTypeDefinition = dataTypes.get(propertyType);
			if (dataTypeDefinition == null) {
				log.debug("The type {} of property cannot be found.", propertyType);
				return StorageOperationStatus.INVALID_TYPE;
			}

			StorageOperationStatus status = validateAndUpdateComplexValue(propertyDefinition, propertyType, value, dataTypeDefinition, dataTypes);

			return status;

		}
		String innerType = null;

		Either<String, TitanOperationStatus> checkInnerType = getInnerType(type, () -> propertyDefinition.getSchema());
		if (checkInnerType.isRight()) {
			return StorageOperationStatus.INVALID_TYPE;
		}
		innerType = checkInnerType.left().value();

		log.trace("After validating property type {}", propertyType);

		boolean isValidProperty = isValidValue(type, value, innerType, dataTypes);
		if (false == isValidProperty) {
			log.info("The value {} of property from type {} is invalid", value, type);
			return StorageOperationStatus.INVALID_VALUE;
		}

		PropertyValueConverter converter = type.getConverter();

		if (isEmptyValue(value)) {
			log.debug("Default value was not sent for property {}. Set default value to {}", propertyDefinition.getName(), EMPTY_VALUE);
			propertyDefinition.setDefaultValue(EMPTY_VALUE);
		} else if (false == isEmptyValue(value)) {
			String convertedValue = converter.convert(value, innerType, dataTypes);
			propertyDefinition.setDefaultValue(convertedValue);
		}
		return StorageOperationStatus.OK;
	}

	public Either<PropertyData, TitanOperationStatus> addPropertyToGraph(String propertyName, PropertyDefinition propertyDefinition, String resourceId) {

		ResourceMetadataData resourceData = new ResourceMetadataData();
		resourceData.getMetadataDataDefinition().setUniqueId(resourceId);

		List<PropertyConstraint> constraints = propertyDefinition.getConstraints();

		propertyDefinition.setUniqueId(UniqueIdBuilder.buildComponentPropertyUniqueId(resourceId, propertyName));
		PropertyData propertyData = new PropertyData(propertyDefinition, convertConstraintsToString(constraints));

		log.debug("Before adding property to graph {}", propertyData);
		Either<PropertyData, TitanOperationStatus> createNodeResult = titanGenericDao.createNode(propertyData, PropertyData.class);
		log.debug("After adding property to graph {}", propertyData);
		if (createNodeResult.isRight()) {
			TitanOperationStatus operationStatus = createNodeResult.right().value();
			log.error("Failed to add property {} to graph. status is {}", propertyName, operationStatus);
			return Either.right(operationStatus);
		}

		Map<String, Object> props = new HashMap<String, Object>();
		props.put(GraphPropertiesDictionary.NAME.getProperty(), propertyName);
		Either<GraphRelation, TitanOperationStatus> createRelResult = titanGenericDao.createRelation(resourceData, propertyData, GraphEdgeLabels.PROPERTY, props);
		if (createRelResult.isRight()) {
			TitanOperationStatus operationStatus = createNodeResult.right().value();
			log.error("Failed to associate resource {} to property {} in graph. status is {}", resourceId, propertyName, operationStatus);
			return Either.right(operationStatus);
		}

		return Either.left(createNodeResult.left().value());

	}

	public TitanOperationStatus addPropertyToGraphByVertex(TitanVertex metadataVertex, String propertyName, PropertyDefinition propertyDefinition, String resourceId) {

		List<PropertyConstraint> constraints = propertyDefinition.getConstraints();

		propertyDefinition.setUniqueId(UniqueIdBuilder.buildComponentPropertyUniqueId(resourceId, propertyName));
		PropertyData propertyData = new PropertyData(propertyDefinition, convertConstraintsToString(constraints));

		log.debug("Before adding property to graph {}", propertyData);
		Either<TitanVertex, TitanOperationStatus> createNodeResult = titanGenericDao.createNode(propertyData);
		log.debug("After adding property to graph {}", propertyData);
		if (createNodeResult.isRight()) {
			TitanOperationStatus operationStatus = createNodeResult.right().value();
			log.error("Failed to add property {} to graph. status is ", propertyName, operationStatus);
			return operationStatus;
		}

		Map<String, Object> props = new HashMap<String, Object>();
		props.put(GraphPropertiesDictionary.NAME.getProperty(), propertyName);
		TitanVertex propertyVertex = createNodeResult.left().value();
		TitanOperationStatus createRelResult = titanGenericDao.createEdge(metadataVertex, propertyVertex, GraphEdgeLabels.PROPERTY, props);
		if (!createRelResult.equals(TitanOperationStatus.OK)) {
			log.error("Failed to associate resource {} to property {} in graph. status is {}", resourceId, propertyName, createRelResult);
			return createRelResult;
		}

		return createRelResult;

	}

	public TitanGenericDao getTitanGenericDao() {
		return titanGenericDao;
	}

	// public Either<PropertyData, StorageOperationStatus>
	// deletePropertyFromGraphFromBl(String propertyId) {
	//
	// }

	public Either<PropertyData, StorageOperationStatus> deleteProperty(String propertyId) {
		Either<PropertyData, TitanOperationStatus> either = deletePropertyFromGraph(propertyId);
		if (either.isRight()) {
			StorageOperationStatus storageStatus = DaoStatusConverter.convertTitanStatusToStorageStatus(either.right().value());
			return Either.right(storageStatus);
		}
		return Either.left(either.left().value());
	}

	public Either<PropertyData, TitanOperationStatus> deletePropertyFromGraph(String propertyId) {
		log.debug("Before deleting property from graph {}", propertyId);
		return titanGenericDao.deleteNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Property), propertyId, PropertyData.class);
	}

	public Either<PropertyData, StorageOperationStatus> updateProperty(String propertyId, PropertyDefinition newPropertyDefinition, Map<String, DataTypeDefinition> dataTypes) {

		StorageOperationStatus validateAndUpdateProperty = validateAndUpdateProperty(newPropertyDefinition, dataTypes);
		if (validateAndUpdateProperty != StorageOperationStatus.OK) {
			return Either.right(validateAndUpdateProperty);
		}

		Either<PropertyData, TitanOperationStatus> either = updatePropertyFromGraph(propertyId, newPropertyDefinition);
		if (either.isRight()) {
			StorageOperationStatus storageStatus = DaoStatusConverter.convertTitanStatusToStorageStatus(either.right().value());
			return Either.right(storageStatus);
		}
		return Either.left(either.left().value());
	}

	public Either<PropertyData, TitanOperationStatus> updatePropertyFromGraph(String propertyId, PropertyDefinition propertyDefinition) {
		if (log.isDebugEnabled())
			log.debug("Before updating property on graph {}", propertyId);

		// get the original property data
		Either<PropertyData, TitanOperationStatus> statusProperty = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Property), propertyId, PropertyData.class);
		if (statusProperty.isRight()) {
			log.debug("Problem while get property with id {}. Reason - {}", propertyId, statusProperty.right().value().name());
			return Either.right(statusProperty.right().value());
		}
		PropertyData orgPropertyData = statusProperty.left().value();
		PropertyDataDefinition orgPropertyDataDefinition = orgPropertyData.getPropertyDataDefinition();

		// create new property data to update
		PropertyData newPropertyData = new PropertyData();
		newPropertyData.setPropertyDataDefinition(propertyDefinition);
		PropertyDataDefinition newPropertyDataDefinition = newPropertyData.getPropertyDataDefinition();

		// update the original property data with new values
		if (orgPropertyDataDefinition.getDefaultValue() == null) {
			orgPropertyDataDefinition.setDefaultValue(newPropertyDataDefinition.getDefaultValue());
		} else {
			if (!orgPropertyDataDefinition.getDefaultValue().equals(newPropertyDataDefinition.getDefaultValue())) {
				orgPropertyDataDefinition.setDefaultValue(newPropertyDataDefinition.getDefaultValue());
			}
		}
		if (orgPropertyDataDefinition.getDescription() == null) {
			orgPropertyDataDefinition.setDescription(newPropertyDataDefinition.getDescription());
		} else {
			if (!orgPropertyDataDefinition.getDescription().equals(newPropertyDataDefinition.getDescription())) {
				orgPropertyDataDefinition.setDescription(newPropertyDataDefinition.getDescription());
			}
		}
		if (!orgPropertyDataDefinition.getType().equals(newPropertyDataDefinition.getType())) {
			orgPropertyDataDefinition.setType(newPropertyDataDefinition.getType());
		}
		if (newPropertyData.getConstraints() != null) {
			orgPropertyData.setConstraints(newPropertyData.getConstraints());
		}
		orgPropertyDataDefinition.setSchema(newPropertyDataDefinition.getSchema());

		return titanGenericDao.updateNode(orgPropertyData, PropertyData.class);
	}

	/**
	 * FOR TEST ONLY
	 * 
	 * @param titanGenericDao
	 */
	public void setTitanGenericDao(TitanGenericDao titanGenericDao) {
		this.titanGenericDao = titanGenericDao;
	}

	public Either<PropertyData, TitanOperationStatus> addPropertyToNodeType(String propertyName, PropertyDefinition propertyDefinition, NodeTypeEnum nodeType, String uniqueId) {

		List<PropertyConstraint> constraints = propertyDefinition.getConstraints();

		propertyDefinition.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(uniqueId, propertyName));
		PropertyData propertyData = new PropertyData(propertyDefinition, convertConstraintsToString(constraints));

		if (log.isDebugEnabled())
			log.debug("Before adding property to graph {}", propertyData);
		Either<PropertyData, TitanOperationStatus> createNodeResult = titanGenericDao.createNode(propertyData, PropertyData.class);
		if (log.isDebugEnabled())
			log.debug("After adding property to graph {}", propertyData);
		if (createNodeResult.isRight()) {
			TitanOperationStatus operationStatus = createNodeResult.right().value();
			log.error("Failed to add property {} to graph. status is {}", propertyName, operationStatus);
			return Either.right(operationStatus);
		}

		Map<String, Object> props = new HashMap<String, Object>();
		props.put(GraphPropertiesDictionary.NAME.getProperty(), propertyName);

		UniqueIdData uniqueIdData = new UniqueIdData(nodeType, uniqueId);
		log.debug("Before associating {} to property {}", uniqueIdData, propertyName);
		Either<GraphRelation, TitanOperationStatus> createRelResult = titanGenericDao.createRelation(uniqueIdData, propertyData, GraphEdgeLabels.PROPERTY, props);
		if (createRelResult.isRight()) {
			TitanOperationStatus operationStatus = createNodeResult.right().value();
			log.error("Failed to associate resource {} to property {} in graph. status is {}", uniqueId, propertyName, operationStatus);
			return Either.right(operationStatus);
		}

		return Either.left(createNodeResult.left().value());

	}

	public Either<Map<String, PropertyDefinition>, TitanOperationStatus> findPropertiesOfNode(NodeTypeEnum nodeType, String uniqueId) {

		Map<String, PropertyDefinition> resourceProps = new HashMap<String, PropertyDefinition>();

		Either<List<ImmutablePair<PropertyData, GraphEdge>>, TitanOperationStatus> childrenNodes = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(nodeType), uniqueId, GraphEdgeLabels.PROPERTY, NodeTypeEnum.Property,
				PropertyData.class);

		if (childrenNodes.isRight()) {
			TitanOperationStatus operationStatus = childrenNodes.right().value();
			return Either.right(operationStatus);
		}

		List<ImmutablePair<PropertyData, GraphEdge>> values = childrenNodes.left().value();
		if (values != null) {

			for (ImmutablePair<PropertyData, GraphEdge> immutablePair : values) {
				GraphEdge edge = immutablePair.getValue();
				String propertyName = (String) edge.getProperties().get(GraphPropertiesDictionary.NAME.getProperty());
				log.debug("Property {} is associated to node {}", propertyName, uniqueId);
				PropertyData propertyData = immutablePair.getKey();
				PropertyDefinition propertyDefinition = this.convertPropertyDataToPropertyDefinition(propertyData, propertyName, uniqueId);
				resourceProps.put(propertyName, propertyDefinition);
			}

		}

		log.debug("The properties associated to node {} are {}", uniqueId, resourceProps);
		return Either.left(resourceProps);
	}

    public Either<Map<String, PropertyDefinition>, StorageOperationStatus> deletePropertiesAssociatedToNode(NodeTypeEnum nodeType, String uniqueId) {
	    return deleteAllPropertiesAssociatedToNode(nodeType, uniqueId)
                .right()
                .bind(err -> err == StorageOperationStatus.OK ? Either.left(Collections.emptyMap()) : Either.right(err));
    }

	public Either<Map<String, PropertyDefinition>, StorageOperationStatus> deleteAllPropertiesAssociatedToNode(NodeTypeEnum nodeType, String uniqueId) {

		Either<Map<String, PropertyDefinition>, TitanOperationStatus> propertiesOfNodeRes = findPropertiesOfNode(nodeType, uniqueId);

		if (propertiesOfNodeRes.isRight()) {
			TitanOperationStatus status = propertiesOfNodeRes.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				return Either.right(StorageOperationStatus.OK);
			}
			return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
		}

		Map<String, PropertyDefinition> value = propertiesOfNodeRes.left().value();
		for (PropertyDefinition propertyDefinition : value.values()) {

			String propertyUid = propertyDefinition.getUniqueId();
			Either<PropertyData, TitanOperationStatus> deletePropertyRes = deletePropertyFromGraph(propertyUid);
			if (deletePropertyRes.isRight()) {
				log.error("Failed to delete property with id {}", propertyUid);
				TitanOperationStatus status = deletePropertyRes.right().value();
				if (status == TitanOperationStatus.NOT_FOUND) {
					status = TitanOperationStatus.INVALID_ID;
				}
				return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
			}

		}

		log.debug("The properties deleted from node {} are {}", uniqueId, value);
		return Either.left(value);
	}

	/**
	 * 
	 * 
	 * @param nodeType
	 * @param uniqueId
	 * @param properties
	 * @return
	 */
	protected TitanOperationStatus findPropertiesOfNode(NodeTypeEnum nodeType, String uniqueId, List<PropertyDefinition> properties) {

		Either<List<ImmutablePair<PropertyData, GraphEdge>>, TitanOperationStatus> childrenNodes = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(nodeType), uniqueId, GraphEdgeLabels.PROPERTY, NodeTypeEnum.Property,
				PropertyData.class);

		if (childrenNodes.isRight()) {
			TitanOperationStatus status = childrenNodes.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				status = TitanOperationStatus.OK;
			}
			return status;
		}

		List<ImmutablePair<PropertyData, GraphEdge>> values = childrenNodes.left().value();
		if (values != null) {

			for (ImmutablePair<PropertyData, GraphEdge> immutablePair : values) {
				GraphEdge edge = immutablePair.getValue();
				String propertyName = (String) edge.getProperties().get(GraphPropertiesDictionary.NAME.getProperty());
				if (log.isDebugEnabled())
					log.debug("Property {} is associated to node {}", propertyName, uniqueId);
				PropertyData propertyData = immutablePair.getKey();
				PropertyDefinition propertyDefinition = this.convertPropertyDataToPropertyDefinition(propertyData, propertyName, uniqueId);
				//Adds parent property to List if it hasn't been overrided in one of the children
				if(!properties.stream().filter(p -> p.getName().equals(propertyDefinition.getName())).findAny().isPresent()){
					properties.add(propertyDefinition);
				}

				if (log.isTraceEnabled())
					log.trace("findPropertiesOfNode - property {} associated to node {}", propertyDefinition, uniqueId);
			}

		}

		return TitanOperationStatus.OK;
	}
/**
 * Checks existence of a property with the same name belonging to the same resource
 * or existence of property with the same name and different type (including derived from hierarchy)
 * @param properties
 * @param resourceUid
 * @param propertyName
 * @param propertyType
 * @return
 */
	public boolean isPropertyExist(List<PropertyDefinition> properties, String resourceUid, String propertyName, String propertyType) {
		boolean result = false;
		if (!CollectionUtils.isEmpty(properties)) {
			for (PropertyDefinition propertyDefinition : properties) {
	
				if ( propertyDefinition.getName().equals(propertyName) &&
						(propertyDefinition.getParentUniqueId().equals(resourceUid) || !propertyDefinition.getType().equals(propertyType)) ) {
					result = true;
					break;
				}
			}
		}
		return result;
	}

	/**
	 * add property to resource instance
	 * 
	 * @param innerType
	 *            TODO // * @param resourceInstanceProperty // * @param resourceInstanceId // * @param index
	 * 
	 * @return
	 */
	/*
	 * public Either<PropertyValueData, TitanOperationStatus> addPropertyToResourceInstance( ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId, Integer index) {
	 * 
	 * Either<ComponentInstanceData, TitanOperationStatus> findResInstanceRes = titanGenericDao .getNode(UniqueIdBuilder .getKeyByNodeType(NodeTypeEnum.ResourceInstance), resourceInstanceId, ComponentInstanceData.class);
	 * 
	 * if (findResInstanceRes.isRight()) { TitanOperationStatus status = findResInstanceRes.right().value(); if (status == TitanOperationStatus.NOT_FOUND) { status = TitanOperationStatus.INVALID_ID; } return Either.right(status); }
	 * 
	 * String propertyId = resourceInstanceProperty.getUniqueId(); Either<PropertyData, TitanOperationStatus> findPropertyDefRes = titanGenericDao .getNode(UniqueIdBuilder .getKeyByNodeType(NodeTypeEnum.Property), propertyId, PropertyData.class);
	 * 
	 * if (findPropertyDefRes.isRight()) { TitanOperationStatus status = findPropertyDefRes.right().value(); if (status == TitanOperationStatus.NOT_FOUND) { status = TitanOperationStatus.INVALID_ID; } return Either.right(status); }
	 * 
	 * String valueUniqueUid = resourceInstanceProperty.getValueUniqueUid(); if (valueUniqueUid == null) {
	 * 
	 * PropertyData propertyData = findPropertyDefRes.left().value(); ComponentInstanceData resourceInstanceData = findResInstanceRes.left().value();
	 * 
	 * ImmutablePair<TitanOperationStatus, String> isPropertyValueExists = findPropertyValue(resourceInstanceId, propertyId); if (isPropertyValueExists.getLeft() == TitanOperationStatus.ALREADY_EXIST) { log.debug("The property " + propertyId +
	 * " already added to the resource instance " + resourceInstanceId); resourceInstanceProperty.setValueUniqueUid(isPropertyValueExists.getRight ()); Either<PropertyValueData, TitanOperationStatus> updatePropertyOfResourceInstance =
	 * updatePropertyOfResourceInstance(resourceInstanceProperty, resourceInstanceId); if (updatePropertyOfResourceInstance.isRight()) { BeEcompErrorManager.getInstance().logInternalFlowError( "UpdatePropertyValueOnComponentInstance",
	 * "Failed to update property value on instance. Status is " + updatePropertyOfResourceInstance.right().value(), ErrorSeverity.ERROR); return Either.right(updatePropertyOfResourceInstance.right().value()); } return
	 * Either.left(updatePropertyOfResourceInstance.left().value()); }
	 * 
	 * if (isPropertyValueExists.getLeft() != TitanOperationStatus.NOT_FOUND) { 
	 * log.debug("After finding property value of {} on componenet instance {}", propertyId, resourceInstanceId); 
	 * return Either.right(isPropertyValueExists.getLeft()); }
	 * 
	 * String propertyType = propertyData.getPropertyDataDefinition().getType(); String value = resourceInstanceProperty.getValue(); Either<Object, Boolean> isValid = validateAndUpdatePropertyValue(propertyType, value);
	 * 
	 * String newValue = value; if (isValid.isRight()) { Boolean res = isValid.right().value(); if (res == false) { return Either.right(TitanOperationStatus.ILLEGAL_ARGUMENT); } } else { Object object = isValid.left().value(); if (object != null) {
	 * newValue = object.toString(); } }
	 * 
	 * String uniqueId = UniqueIdBuilder.buildResourceInstancePropertyValueUid( resourceInstanceData.getUniqueId(), index); PropertyValueData propertyValueData = new PropertyValueData(); propertyValueData.setUniqueId(uniqueId);
	 * propertyValueData.setValue(newValue);
	 * 
	 * ImmutablePair<String, Boolean> pair = validateAndUpdateRules(propertyType, resourceInstanceProperty.getRules()); if (pair.getRight() != null && pair.getRight() == false) { BeEcompErrorManager.getInstance().
	 * logBeInvalidValueError("Add property value", pair.getLeft(), resourceInstanceProperty.getName(), propertyType); return Either.right(TitanOperationStatus.ILLEGAL_ARGUMENT); } addRulesToNewPropertyValue(propertyValueData,
	 * resourceInstanceProperty, resourceInstanceId);
	 * 
	 * log.debug("Before adding property value to graph {}", propertyValueData); 
	 * Either<PropertyValueData, TitanOperationStatus> createNodeResult = titanGenericDao .createNode(propertyValueData, PropertyValueData.class);
	 * log.debug("After adding property value to graph {}", propertyValueData);
	 * 
	 * Either<GraphRelation, TitanOperationStatus> createRelResult = titanGenericDao .createRelation(propertyValueData, propertyData, GraphEdgeLabels.PROPERTY_IMPL, null);
	 * 
	 * if (createRelResult.isRight()) { TitanOperationStatus operationStatus = createNodeResult.right() .value(); //TODO: change logger log.error("Failed to associate property value " + uniqueId + " to property " + propertyId +
	 * " in graph. status is " + operationStatus); return Either.right(operationStatus); }
	 * 
	 * createRelResult = titanGenericDao .createRelation(resourceInstanceData, propertyValueData, GraphEdgeLabels.PROPERTY_VALUE, null);
	 * 
	 * if (createRelResult.isRight()) { TitanOperationStatus operationStatus = createNodeResult.right() .value(); //TODO: change logger log.error("Failed to associate resource instance " + resourceInstanceId + " property value " + uniqueId +
	 * " in graph. status is " + operationStatus); return Either.right(operationStatus); }
	 * 
	 * return Either.left(createNodeResult.left().value()); } else { log.error("property value already exists."); return Either.right(TitanOperationStatus.ALREADY_EXIST); }
	 * 
	 * }
	 */
	public ImmutablePair<String, Boolean> validateAndUpdateRules(String propertyType, List<PropertyRule> rules, String innerType, Map<String, DataTypeDefinition> dataTypes, boolean isValidate) {

		if (rules == null || rules.isEmpty() == true) {
			return new ImmutablePair<String, Boolean>(null, true);
		}

		for (PropertyRule rule : rules) {
			String value = rule.getValue();
			Either<Object, Boolean> updateResult = validateAndUpdatePropertyValue(propertyType, value, isValidate, innerType, dataTypes);
			if (updateResult.isRight()) {
				Boolean status = updateResult.right().value();
				if (status == false) {
					return new ImmutablePair<String, Boolean>(value, status);
				}
			} else {
				String newValue = null;
				Object object = updateResult.left().value();
				if (object != null) {
					newValue = object.toString();
				}
				rule.setValue(newValue);
			}
		}

		return new ImmutablePair<String, Boolean>(null, true);
	}

	public void addRulesToNewPropertyValue(PropertyValueData propertyValueData, ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId) {

		List<PropertyRule> rules = resourceInstanceProperty.getRules();
		if (rules == null) {
			PropertyRule propertyRule = buildRuleFromPath(propertyValueData, resourceInstanceProperty, resourceInstanceId);
			rules = new ArrayList<>();
			rules.add(propertyRule);
		} else {
			rules = sortRules(rules);
		}

		propertyValueData.setRules(rules);
	}

	private PropertyRule buildRuleFromPath(PropertyValueData propertyValueData, ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId) {
		List<String> path = resourceInstanceProperty.getPath();
		// FOR BC. Since old Property values on VFC/VF does not have rules on
		// graph.
		// Update could be done on one level only, thus we can use this
		// operation to avoid migration.
		if (path == null || path.isEmpty() == true) {
			path = new ArrayList<>();
			path.add(resourceInstanceId);
		}
		PropertyRule propertyRule = new PropertyRule();
		propertyRule.setRule(path);
		propertyRule.setValue(propertyValueData.getValue());
		return propertyRule;
	}

	private List<PropertyRule> sortRules(List<PropertyRule> rules) {

		// TODO: sort the rules by size and binary representation.
		// (x, y, .+) --> 110 6 priority 1
		// (x, .+, z) --> 101 5 priority 2

		return rules;
	}

	public ImmutablePair<TitanOperationStatus, String> findPropertyValue(String resourceInstanceId, String propertyId) {

		log.debug("Going to check whether the property {} already added to resource instance {}", propertyId, resourceInstanceId);

		Either<List<ComponentInstanceProperty>, TitanOperationStatus> getAllRes = this.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceId);
		if (getAllRes.isRight()) {
			TitanOperationStatus status = getAllRes.right().value();
			log.trace("After fetching all properties of resource instance {}. Status is {}", resourceInstanceId, status);
			return new ImmutablePair<TitanOperationStatus, String>(status, null);
		}

		List<ComponentInstanceProperty> list = getAllRes.left().value();
		if (list != null) {
			for (ComponentInstanceProperty instanceProperty : list) {
				String propertyUniqueId = instanceProperty.getUniqueId();
				String valueUniqueUid = instanceProperty.getValueUniqueUid();
				log.trace("Go over property {} under resource instance {}. valueUniqueId = {}", propertyUniqueId, resourceInstanceId, valueUniqueUid);
				if (propertyId.equals(propertyUniqueId) && valueUniqueUid != null) {
					log.debug("The property {} already created under resource instance {}", propertyId, resourceInstanceId);
					return new ImmutablePair<TitanOperationStatus, String>(TitanOperationStatus.ALREADY_EXIST, valueUniqueUid);
				}
			}
		}

		return new ImmutablePair<TitanOperationStatus, String>(TitanOperationStatus.NOT_FOUND, null);
	}

	/**
	 * update value of property on resource instance
	 * 
	 * @param resourceInstanceProperty
	 * @param resourceInstanceId
	 * @return
	 */
	/*
	 * public Either<PropertyValueData, TitanOperationStatus> updatePropertyOfResourceInstance( ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId) {
	 * 
	 * /// #RULES SUPPORT /// Ignore rules received from client till support resourceInstanceProperty.setRules(null); /// /// Either<ComponentInstanceData, TitanOperationStatus> findResInstanceRes = titanGenericDao .getNode(UniqueIdBuilder
	 * .getKeyByNodeType(NodeTypeEnum.ResourceInstance), resourceInstanceId, ComponentInstanceData.class);
	 * 
	 * if (findResInstanceRes.isRight()) { TitanOperationStatus status = findResInstanceRes.right().value(); if (status == TitanOperationStatus.NOT_FOUND) { status = TitanOperationStatus.INVALID_ID; } return Either.right(status); }
	 * 
	 * String propertyId = resourceInstanceProperty.getUniqueId(); Either<PropertyData, TitanOperationStatus> findPropertyDefRes = titanGenericDao .getNode(UniqueIdBuilder .getKeyByNodeType(NodeTypeEnum.Property), propertyId, PropertyData.class);
	 * 
	 * if (findPropertyDefRes.isRight()) { TitanOperationStatus status = findPropertyDefRes.right().value(); return Either.right(status); }
	 * 
	 * String valueUniqueUid = resourceInstanceProperty.getValueUniqueUid(); if (valueUniqueUid == null) { return Either.right(TitanOperationStatus.INVALID_ID); } else { Either<PropertyValueData, TitanOperationStatus> findPropertyValueRes =
	 * titanGenericDao .getNode(UniqueIdBuilder .getKeyByNodeType(NodeTypeEnum.PropertyValue), valueUniqueUid, PropertyValueData.class); if (findPropertyValueRes.isRight()) { TitanOperationStatus status = findPropertyValueRes.right().value(); if
	 * (status == TitanOperationStatus.NOT_FOUND) { status = TitanOperationStatus.INVALID_ID; } return Either.right(status); }
	 * 
	 * String value = resourceInstanceProperty.getValue();
	 * 
	 * Either<ImmutablePair<PropertyData, GraphEdge>, TitanOperationStatus> child = titanGenericDao.getChild(UniqueIdBuilder .getKeyByNodeType(NodeTypeEnum.PropertyValue), valueUniqueUid, GraphEdgeLabels.PROPERTY_IMPL, NodeTypeEnum.Property,
	 * PropertyData.class);
	 * 
	 * if (child.isRight()) { TitanOperationStatus status = child.right().value(); if (status == TitanOperationStatus.NOT_FOUND) { status = TitanOperationStatus.INVALID_ID; } return Either.right(status); }
	 * 
	 * PropertyData propertyData = child.left().value().left; String propertyType = propertyData.getPropertyDataDefinition().getType();
	 * 
	 * log.debug("The type of the property {} is {}", propertyData.getUniqueId(), propertyType);
	 * 
	 * Either<Object, Boolean> isValid = validateAndUpdatePropertyValue(propertyType, value);
	 * 
	 * String newValue = value; if (isValid.isRight()) { Boolean res = isValid.right().value(); if (res == false) { return Either.right(TitanOperationStatus.ILLEGAL_ARGUMENT); } } else { Object object = isValid.left().value(); if (object != null) {
	 * newValue = object.toString(); } } PropertyValueData propertyValueData = findPropertyValueRes.left().value(); log.debug("Going to update property value from " + propertyValueData.getValue() + " to " + newValue);
	 * propertyValueData.setValue(newValue);
	 * 
	 * ImmutablePair<String, Boolean> pair = validateAndUpdateRules(propertyType, resourceInstanceProperty.getRules()); if (pair.getRight() != null && pair.getRight() == false) { BeEcompErrorManager.getInstance().
	 * logBeInvalidValueError("Add property value", pair.getLeft(), resourceInstanceProperty.getName(), propertyType); return Either.right(TitanOperationStatus.ILLEGAL_ARGUMENT); } updateRulesInPropertyValue(propertyValueData,
	 * resourceInstanceProperty, resourceInstanceId);
	 * 
	 * Either<PropertyValueData, TitanOperationStatus> updateRes = titanGenericDao.updateNode(propertyValueData, PropertyValueData.class); if (updateRes.isRight()) { TitanOperationStatus status = updateRes.right().value(); return
	 * Either.right(status); } else { return Either.left(updateRes.left().value()); } }
	 * 
	 * }
	 */

	public void updateRulesInPropertyValue(PropertyValueData propertyValueData, ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId) {

		List<PropertyRule> currentRules = propertyValueData.getRules();

		List<PropertyRule> rules = resourceInstanceProperty.getRules();
		// if rules are not supported.
		if (rules == null) {

			PropertyRule propertyRule = buildRuleFromPath(propertyValueData, resourceInstanceProperty, resourceInstanceId);
			rules = new ArrayList<>();
			rules.add(propertyRule);

			if (currentRules != null) {
				rules = mergeRules(currentRules, rules);
			}

		} else {
			// Full mode. all rules are sent in update operation.
			rules = sortRules(rules);
		}

		propertyValueData.setRules(rules);

	}

	private List<PropertyRule> mergeRules(List<PropertyRule> currentRules, List<PropertyRule> newRules) {

		List<PropertyRule> mergedRules = new ArrayList<>();

		if (newRules == null || newRules.isEmpty() == true) {
			return currentRules;
		}

		for (PropertyRule rule : currentRules) {
			PropertyRule propertyRule = new PropertyRule(rule.getRule(), rule.getValue());
			mergedRules.add(propertyRule);
		}

		for (PropertyRule rule : newRules) {
			PropertyRule foundRule = findRuleInList(rule, mergedRules);
			if (foundRule != null) {
				foundRule.setValue(rule.getValue());
			} else {
				mergedRules.add(rule);
			}
		}

		return mergedRules;
	}

	private PropertyRule findRuleInList(PropertyRule rule, List<PropertyRule> rules) {

		if (rules == null || rules.isEmpty() == true || rule.getRule() == null || rule.getRule().isEmpty() == true) {
			return null;
		}

		PropertyRule foundRule = null;
		for (PropertyRule propertyRule : rules) {
			if (rule.getRuleSize() != propertyRule.getRuleSize()) {
				continue;
			}
			boolean equals = propertyRule.compareRule(rule);
			if (equals == true) {
				foundRule = propertyRule;
				break;
			}
		}

		return foundRule;
	}

	/**
	 * return all properties associated to resource instance. The result does contains the property unique id but not its type, default value...
	 * 
	 * @param resourceInstanceUid
	 * @return
	 */
	public Either<List<ComponentInstanceProperty>, TitanOperationStatus> getAllPropertiesOfResourceInstanceOnlyPropertyDefId(String resourceInstanceUid) {

		return getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid, NodeTypeEnum.ResourceInstance);

	}

	/*
	 * public Either<ComponentInstanceProperty, StorageOperationStatus> addPropertyValueToResourceInstance( ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId, Integer index, boolean inTransaction) {
	 * 
	 * /// #RULES SUPPORT /// Ignore rules received from client till support resourceInstanceProperty.setRules(null); /// ///
	 * 
	 * Either<ComponentInstanceProperty, StorageOperationStatus> result = null;
	 * 
	 * try {
	 * 
	 * Either<PropertyValueData, TitanOperationStatus> eitherStatus = this .addPropertyToResourceInstance(resourceInstanceProperty, resourceInstanceId, index);
	 * 
	 * if (eitherStatus.isRight()) { log.error( "Failed to add property value {} to resource instance {} in Graph. status is {}" , resourceInstanceProperty, resourceInstanceId, eitherStatus.right().value().name()); result =
	 * Either.right(DaoStatusConverter .convertTitanStatusToStorageStatus(eitherStatus.right() .value())); return result; } else { PropertyValueData propertyValueData = eitherStatus.left() .value();
	 * 
	 * ComponentInstanceProperty propertyValueResult = buildResourceInstanceProperty( propertyValueData, resourceInstanceProperty);
	 * 
	 * log.debug("The returned ResourceInstanceProperty is  {}", propertyValueResult); result = Either.left(propertyValueResult); return result; } }
	 * 
	 * finally { if (false == inTransaction) { if (result == null || result.isRight()) { log.error("Going to execute rollback on graph."); titanGenericDao.rollback(); } else { log.debug("Going to execute commit on graph."); titanGenericDao.commit();
	 * } } }
	 * 
	 * }
	 * 
	 * public Either<ComponentInstanceProperty, StorageOperationStatus> updatePropertyValueInResourceInstance( ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId, boolean inTransaction) {
	 * 
	 * Either<ComponentInstanceProperty, StorageOperationStatus> result = null;
	 * 
	 * try { //TODO: verify validUniqueId exists Either<PropertyValueData, TitanOperationStatus> eitherStatus = this .updatePropertyOfResourceInstance(resourceInstanceProperty, resourceInstanceId);
	 * 
	 * if (eitherStatus.isRight()) { log.error( "Failed to add property value {} to resource instance {} in Graph. status is {}" , resourceInstanceProperty, resourceInstanceId, eitherStatus.right().value().name()); result =
	 * Either.right(DaoStatusConverter .convertTitanStatusToStorageStatus(eitherStatus.right() .value())); return result; } else { PropertyValueData propertyValueData = eitherStatus.left() .value();
	 * 
	 * ComponentInstanceProperty propertyValueResult = buildResourceInstanceProperty( propertyValueData, resourceInstanceProperty);
	 * 
	 * log.debug("The returned ResourceInstanceProperty is  {}", propertyValueResult); result = Either.left(propertyValueResult); return result; } }
	 * 
	 * finally { if (false == inTransaction) { if (result == null || result.isRight()) { log.error("Going to execute rollback on graph."); titanGenericDao.rollback(); } else { log.debug("Going to execute commit on graph."); titanGenericDao.commit();
	 * } } }
	 * 
	 * }
	 */

	public Either<PropertyValueData, TitanOperationStatus> removePropertyOfResourceInstance(String propertyValueUid, String resourceInstanceId) {

		Either<ComponentInstanceData, TitanOperationStatus> findResInstanceRes = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), resourceInstanceId, ComponentInstanceData.class);

		if (findResInstanceRes.isRight()) {
			TitanOperationStatus status = findResInstanceRes.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				status = TitanOperationStatus.INVALID_ID;
			}
			return Either.right(status);
		}

		Either<PropertyValueData, TitanOperationStatus> findPropertyDefRes = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PropertyValue), propertyValueUid, PropertyValueData.class);

		if (findPropertyDefRes.isRight()) {
			TitanOperationStatus status = findPropertyDefRes.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				status = TitanOperationStatus.INVALID_ID;
			}
			return Either.right(status);
		}

		Either<GraphRelation, TitanOperationStatus> relation = titanGenericDao.getRelation(findResInstanceRes.left().value(), findPropertyDefRes.left().value(), GraphEdgeLabels.PROPERTY_VALUE);
		if (relation.isRight()) {
			// TODO: add error in case of error
			TitanOperationStatus status = relation.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				status = TitanOperationStatus.INVALID_ID;
			}
			return Either.right(status);
		}

		Either<PropertyValueData, TitanOperationStatus> deleteNode = titanGenericDao.deleteNode(findPropertyDefRes.left().value(), PropertyValueData.class);
		if (deleteNode.isRight()) {
			return Either.right(deleteNode.right().value());
		}
		PropertyValueData value = deleteNode.left().value();
		return Either.left(value);

	}

	public Either<ComponentInstanceProperty, StorageOperationStatus> removePropertyValueFromResourceInstance(String propertyValueUid, String resourceInstanceId, boolean inTransaction) {

		Either<ComponentInstanceProperty, StorageOperationStatus> result = null;

		try {

			Either<PropertyValueData, TitanOperationStatus> eitherStatus = this.removePropertyOfResourceInstance(propertyValueUid, resourceInstanceId);

			if (eitherStatus.isRight()) {
				log.error("Failed to remove property value {} from resource instance {} in Graph. status is {}", propertyValueUid, resourceInstanceId, eitherStatus.right().value().name());
				result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(eitherStatus.right().value()));
				return result;
			} else {
				PropertyValueData propertyValueData = eitherStatus.left().value();

				ComponentInstanceProperty propertyValueResult = new ComponentInstanceProperty();
				propertyValueResult.setUniqueId(resourceInstanceId);
				propertyValueResult.setValue(propertyValueData.getValue());

				log.debug("The returned ResourceInstanceProperty is  {}", propertyValueResult);
				result = Either.left(propertyValueResult);
				return result;
			}
		}

		finally {
			if (false == inTransaction) {
				if (result == null || result.isRight()) {
					log.error("Going to execute rollback on graph.");
					titanGenericDao.rollback();
				} else {
					log.debug("Going to execute commit on graph.");
					titanGenericDao.commit();
				}
			}
		}

	}

	public ComponentInstanceProperty buildResourceInstanceProperty(PropertyValueData propertyValueData, ComponentInstanceProperty resourceInstanceProperty) {

		String value = propertyValueData.getValue();
		String uid = propertyValueData.getUniqueId();
		ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty(resourceInstanceProperty, value, uid);
		instanceProperty.setPath(resourceInstanceProperty.getPath());

		return instanceProperty;
	}


	public static class PropertyConstraintJacksonDeserializer extends com.fasterxml.jackson.databind.JsonDeserializer<PropertyConstraint> {

		@Override
		public PropertyConstraint deserialize(com.fasterxml.jackson.core.JsonParser json, DeserializationContext context) throws IOException {
			ObjectCodec oc = json.getCodec();
			JsonNode node = oc.readTree(json);
			return null;
		}
	}

	@Override
	public boolean isPropertyDefaultValueValid(IComplexDefaultValue propertyDefinition, Map<String, DataTypeDefinition> dataTypes) {
		if (propertyDefinition == null) {
			return false;
		}
		boolean isValid = false;
		String innerType = null;
		String propertyType = propertyDefinition.getType();
		ToscaPropertyType type = getType(propertyType);
		if (type == ToscaPropertyType.LIST || type == ToscaPropertyType.MAP) {
			SchemaDefinition def = propertyDefinition.getSchema();
			if (def == null) {
				return false;
			}
			PropertyDataDefinition propDef = def.getProperty();
			if (propDef == null) {
				return false;
			}
			innerType = propDef.getType();
		}
		String value = propertyDefinition.getDefaultValue();
		if (type != null) {
			isValid = isValidValue(type, value, innerType, dataTypes);
		} else {
			log.trace("The given type {} is not a pre defined one.", propertyType);

			DataTypeDefinition foundDt = dataTypes.get(propertyType);
			if (foundDt != null) {
				isValid = isValidComplexValue(foundDt, value, dataTypes);
			} else {
				isValid = false;
			}
		}
		return isValid;
	}

	public boolean isPropertyTypeValid(IComplexDefaultValue property) {

		if (property == null) {
			return false;
		}

		if (ToscaPropertyType.isValidType(property.getType()) == null) {

			Either<Boolean, TitanOperationStatus> definedInDataTypes = isDefinedInDataTypes(property.getType());

			if (definedInDataTypes.isRight()) {
				return false;
			} else {
				Boolean isExist = definedInDataTypes.left().value();
				return isExist.booleanValue();
			}

		}
		return true;
	}

	@Override
	public ImmutablePair<String, Boolean> isPropertyInnerTypeValid(IComplexDefaultValue property, Map<String, DataTypeDefinition> dataTypes) {

		if (property == null) {
			return new ImmutablePair<String, Boolean>(null, false);
		}

		SchemaDefinition schema;
		PropertyDataDefinition innerProp;
		String innerType = null;
		if ((schema = property.getSchema()) != null) {
			if ((innerProp = schema.getProperty()) != null) {
				innerType = innerProp.getType();
			}
		}

		ToscaPropertyType innerToscaType = ToscaPropertyType.isValidType(innerType);

		if (innerToscaType == null) {
			DataTypeDefinition dataTypeDefinition = dataTypes.get(innerType);
			if (dataTypeDefinition == null) {
				log.debug("The inner type {} is not a data type.", innerType);
				return new ImmutablePair<String, Boolean>(innerType, false);
			} else {
				log.debug("The inner type {} is a data type. Data type definition is {}", innerType, dataTypeDefinition);
			}
		}

		return new ImmutablePair<String, Boolean>(innerType, true);
	}

	private boolean isValidComplexValue(DataTypeDefinition foundDt, String value, Map<String, DataTypeDefinition> dataTypes) {
		/*
		 * Either<Map<String, DataTypeDefinition>, TitanOperationStatus> allDataTypesRes = getAllDataTypes(); if (allDataTypesRes.isRight()) { TitanOperationStatus status = allDataTypesRes.right().value();
		 * return false; }
		 * 
		 * Map<String, DataTypeDefinition> allDataTypes = allDataTypesRes.left().value();
		 */
		ImmutablePair<JsonElement, Boolean> validateAndUpdate = dataTypeValidatorConverter.validateAndUpdate(value, foundDt, dataTypes);

		log.trace("The result after validating complex value of type {} is {}", foundDt.getName(), validateAndUpdate);

		return validateAndUpdate.right.booleanValue();

	}

	public Either<List<ComponentInstanceProperty>, TitanOperationStatus> getAllPropertiesOfResourceInstanceOnlyPropertyDefId(String resourceInstanceUid, NodeTypeEnum instanceNodeType) {

		Either<TitanVertex, TitanOperationStatus> findResInstanceRes = titanGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(instanceNodeType), resourceInstanceUid);

		if (findResInstanceRes.isRight()) {
			TitanOperationStatus status = findResInstanceRes.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				status = TitanOperationStatus.INVALID_ID;
			}
			return Either.right(status);
		}

		Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> propertyImplNodes = titanGenericDao.getChildrenVertecies(UniqueIdBuilder.getKeyByNodeType(instanceNodeType), resourceInstanceUid, GraphEdgeLabels.PROPERTY_VALUE);

		if (propertyImplNodes.isRight()) {
			TitanOperationStatus status = propertyImplNodes.right().value();
			return Either.right(status);
		}

		List<ImmutablePair<TitanVertex, Edge>> list = propertyImplNodes.left().value();
		if (list == null || true == list.isEmpty()) {
			return Either.right(TitanOperationStatus.NOT_FOUND);
		}

		List<ComponentInstanceProperty> result = new ArrayList<>();
		for (ImmutablePair<TitanVertex, Edge> propertyValue : list) {
			TitanVertex propertyValueDataVertex = propertyValue.getLeft();
			String propertyValueUid = (String) titanGenericDao.getProperty(propertyValueDataVertex, GraphPropertiesDictionary.UNIQUE_ID.getProperty());
			String value = (String) titanGenericDao.getProperty(propertyValueDataVertex, GraphPropertiesDictionary.VALUE.getProperty());

			ImmutablePair<TitanVertex, Edge> propertyDefPair = titanGenericDao.getChildVertex(propertyValueDataVertex, GraphEdgeLabels.PROPERTY_IMPL);
			if (propertyDefPair == null) {
				return Either.right(TitanOperationStatus.NOT_FOUND);
			}

			Map<String, Object> properties = titanGenericDao.getProperties(propertyValueDataVertex);
			PropertyValueData propertyValueData = GraphElementFactory.createElement(NodeTypeEnum.PropertyValue.getName(), GraphElementTypeEnum.Node, properties, PropertyValueData.class);
			String propertyUniqueId = (String) titanGenericDao.getProperty(propertyDefPair.left, GraphPropertiesDictionary.UNIQUE_ID.getProperty());

			ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
			// set property original unique id
			resourceInstanceProperty.setUniqueId(propertyUniqueId);
			// set resource id
			// TODO: esofer add resource id
			resourceInstanceProperty.setParentUniqueId(null);
			// set value
			resourceInstanceProperty.setValue(value);
			// set property value unique id
			resourceInstanceProperty.setValueUniqueUid(propertyValueUid);
			// set rules
			resourceInstanceProperty.setRules(propertyValueData.getRules());

			result.add(resourceInstanceProperty);
		}

		return Either.left(result);
	}

	/**
	 * Find the default value from the list of component instances. Start the search from the second component instance
	 * 
	 * @param pathOfComponentInstances
	 * @param propertyUniqueId
	 * @param defaultValue
	 * @return
	 */
	public Either<String, TitanOperationStatus> findDefaultValueFromSecondPosition(List<String> pathOfComponentInstances, String propertyUniqueId, String defaultValue) {

		log.trace("In find default value: path= {} propertyUniqId={} defaultValue= {}", pathOfComponentInstances, propertyUniqueId, defaultValue);

		if (pathOfComponentInstances == null || pathOfComponentInstances.size() < 2) {
			return Either.left(defaultValue);
		}

		String result = defaultValue;

		for (int i = 1; i < pathOfComponentInstances.size(); i++) {
			String compInstanceId = pathOfComponentInstances.get(i);

			Either<List<ComponentInstanceProperty>, TitanOperationStatus> propertyValuesResult = this.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(compInstanceId, NodeTypeEnum.ResourceInstance);

			log.trace("After fetching properties values of component instance {}. {}", compInstanceId, propertyValuesResult);

			if (propertyValuesResult.isRight()) {
				TitanOperationStatus status = propertyValuesResult.right().value();
				if (status != TitanOperationStatus.NOT_FOUND) {
					return Either.right(status);
				} else {
					continue;
				}
			}

			ComponentInstanceProperty foundCompInstanceProperty = fetchByPropertyUid(propertyValuesResult.left().value(), propertyUniqueId);
			log.trace("After finding the component instance property on{} . {}", compInstanceId, foundCompInstanceProperty);

			if (foundCompInstanceProperty == null) {
				continue;
			}

			List<PropertyRule> rules = getOrBuildRulesIfNotExists(pathOfComponentInstances.size() - i, pathOfComponentInstances.get(i), foundCompInstanceProperty.getRules(), foundCompInstanceProperty.getValue());

			log.trace("Rules of property {} on component instance {} are {}", propertyUniqueId, compInstanceId, rules);
			PropertyRule matchedRule = findMatchRule(pathOfComponentInstances, i, rules);
			log.trace("Match rule is {}", matchedRule);

			if (matchedRule != null) {
				result = matchedRule.getValue();
				break;
			}

		}

		return Either.left(result);

	}

	private ComponentInstanceProperty fetchByPropertyUid(List<ComponentInstanceProperty> list, String propertyUniqueId) {

		ComponentInstanceProperty result = null;

		if (list == null) {
			return null;
		}

		for (ComponentInstanceProperty instProperty : list) {
			if (instProperty.getUniqueId().equals(propertyUniqueId)) {
				result = instProperty;
				break;
			}
		}

		return result;
	}

	private List<PropertyRule> getOrBuildRulesIfNotExists(int ruleSize, String compInstanceId, List<PropertyRule> rules, String value) {

		if (rules != null) {
			return rules;
		}

		rules = buildDefaultRule(compInstanceId, ruleSize, value);

		return rules;

	}

	private List<PropertyRule> getRulesOfPropertyValue(int size, String instanceId, ComponentInstanceProperty componentInstanceProperty) {
		List<PropertyRule> rules = componentInstanceProperty.getRules();
		if (rules == null) {
			rules = buildDefaultRule(instanceId, size, componentInstanceProperty.getValue());
		}
		return rules;
	}

	private List<PropertyRule> buildDefaultRule(String componentInstanceId, int size, String value) {

		List<PropertyRule> rules = new ArrayList<>();
		List<String> rule = new ArrayList<>();
		rule.add(componentInstanceId);
		for (int i = 0; i < size - 1; i++) {
			rule.add(PropertyRule.RULE_ANY_MATCH);
		}
		PropertyRule propertyRule = new PropertyRule(rule, value);
		rules.add(propertyRule);

		return rules;

	}

	private PropertyRule findMatchRule(List<String> pathOfInstances, int level, List<PropertyRule> rules) {

		PropertyRule propertyRule = null;

		String stringForMatch = buildStringForMatch(pathOfInstances, level);

		String firstCompInstance = pathOfInstances.get(level);

		if (rules != null) {

			for (PropertyRule rule : rules) {

				int ruleSize = rule.getRule().size();
				// check the length of the rule equals to the length of the
				// instances path.
				if (ruleSize != pathOfInstances.size() - level) {
					continue;
				}
				// check that the rule starts with correct component instance id
				if (false == checkFirstItem(firstCompInstance, rule.getFirstToken())) {
					continue;
				}

				String secondToken = rule.getToken(2);
				if (secondToken != null && (secondToken.equals(PropertyRule.FORCE_ALL) || secondToken.equals(PropertyRule.ALL))) {
					propertyRule = rule;
					break;
				}

				String patternStr = buildStringForMatch(rule.getRule(), 0);

				Pattern pattern = Pattern.compile(patternStr);

				Matcher matcher = pattern.matcher(stringForMatch);

				if (matcher.matches()) {
					if (log.isTraceEnabled()) {
						log.trace("{} matches the rule {}", stringForMatch, patternStr);
					}
					propertyRule = rule;
					break;
				}
			}

		}

		return propertyRule;
	}

	private boolean checkFirstItem(String left, String right) {
		if (left != null && left.equals(right)) {
			return true;
		}
		return false;
	}

	private String buildStringForMatch(List<String> pathOfInstances, int level) {
		StringBuilder builder = new StringBuilder();

		for (int i = level; i < pathOfInstances.size(); i++) {
			builder.append(pathOfInstances.get(i));
			if (i < pathOfInstances.size() - 1) {
				builder.append("#");
			}
		}
		return builder.toString();
	}

	public void updatePropertyByBestMatch(String propertyUniqueId, ComponentInstanceProperty instanceProperty, Map<String, ComponentInstanceProperty> instanceIdToValue) {

		List<String> pathOfInstances = instanceProperty.getPath();
		int level = 0;
		int size = pathOfInstances.size();
		int numberOfMatches = 0;
		for (String instanceId : pathOfInstances) {
			ComponentInstanceProperty componentInstanceProperty = instanceIdToValue.get(instanceId);

			if (componentInstanceProperty != null) {

				List<PropertyRule> rules = getRulesOfPropertyValue(size - level, instanceId, componentInstanceProperty);
				// If it is the first level instance, then update valueUniuqeId
				// parameter in order to know on update that
				// we should update and not create new node on graph.
				if (level == 0) {
					instanceProperty.setValueUniqueUid(componentInstanceProperty.getValueUniqueUid());
					instanceProperty.setRules(rules);
				}

				PropertyRule rule = findMatchRule(pathOfInstances, level, rules);
				if (rule != null) {
					numberOfMatches++;
					String value = rule.getValue();
					if (numberOfMatches == 1) {
						instanceProperty.setValue(value);
						if (log.isDebugEnabled()) {
							log.debug("Set the value of property {} {} on path {} to be {}", propertyUniqueId, instanceProperty.getName(), pathOfInstances, value);
						}
					} else if (numberOfMatches == 2) {
						// In case of another property value match, then use the
						// value to be the default value of the property.
						instanceProperty.setDefaultValue(value);
						if (log.isDebugEnabled()) {
							log.debug("Set the default value of property {} {} on path {} to be {}", propertyUniqueId, instanceProperty.getName(), pathOfInstances, value);
						}
						break;
					}
				}
			}
			level++;
		}

	}

	/**
	 * 
	 * Add data type to graph.
	 * 
	 * 1. Add data type node
	 * 
	 * 2. Add edge between the former node to its parent(if exists)
	 * 
	 * 3. Add property node and associate it to the node created at #1. (per property & if exists)
	 * 
	 * @param dataTypeDefinition
	 * @return
	 */
	private Either<DataTypeData, TitanOperationStatus> addDataTypeToGraph(DataTypeDefinition dataTypeDefinition) {

		log.debug("Got data type {}", dataTypeDefinition);

		String dtUniqueId = UniqueIdBuilder.buildDataTypeUid(dataTypeDefinition.getName());

		DataTypeData dataTypeData = buildDataTypeData(dataTypeDefinition, dtUniqueId);

		log.debug("Before adding data type to graph. dataTypeData = {}", dataTypeData);
		Either<DataTypeData, TitanOperationStatus> createDataTypeResult = titanGenericDao.createNode(dataTypeData, DataTypeData.class);
		log.debug("After adding data type to graph. status is = {}", createDataTypeResult);

		if (createDataTypeResult.isRight()) {
			TitanOperationStatus operationStatus = createDataTypeResult.right().value();
			log.debug("Failed to data type {} to graph. status is {}", dataTypeDefinition.getName(), operationStatus);
			BeEcompErrorManager.getInstance().logBeFailedAddingNodeTypeError("AddDataType", NodeTypeEnum.DataType.getName());
			return Either.right(operationStatus);
		}

		DataTypeData resultCTD = createDataTypeResult.left().value();
		List<PropertyDefinition> properties = dataTypeDefinition.getProperties();
		Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesToDataType = addPropertiesToDataType(resultCTD.getUniqueId(), properties);
		if (addPropertiesToDataType.isRight()) {
			log.debug("Failed add properties {} to data type {}", properties, dataTypeDefinition.getName());
			return Either.right(addPropertiesToDataType.right().value());
		}

		String derivedFrom = dataTypeDefinition.getDerivedFromName();
		if (derivedFrom != null) {
			log.debug("Before creating relation between data type {} to its parent {}", dtUniqueId, derivedFrom);
			UniqueIdData from = new UniqueIdData(NodeTypeEnum.DataType, dtUniqueId);

			String deriveFromUid = UniqueIdBuilder.buildDataTypeUid(derivedFrom);
			UniqueIdData to = new UniqueIdData(NodeTypeEnum.DataType, deriveFromUid);
			Either<GraphRelation, TitanOperationStatus> createRelation = titanGenericDao.createRelation(from, to, GraphEdgeLabels.DERIVED_FROM, null);
			log.debug("After create relation between capability type {} to its parent {}. status is {}", dtUniqueId, derivedFrom, createRelation);
			if (createRelation.isRight()) {
				return Either.right(createRelation.right().value());
			}
		}

		return Either.left(createDataTypeResult.left().value());

	}

	private DataTypeData buildDataTypeData(DataTypeDefinition dataTypeDefinition, String ctUniqueId) {

		DataTypeData dataTypeData = new DataTypeData(dataTypeDefinition);

		dataTypeData.getDataTypeDataDefinition().setUniqueId(ctUniqueId);
		Long creationDate = dataTypeData.getDataTypeDataDefinition().getCreationTime();
		if (creationDate == null) {
			creationDate = System.currentTimeMillis();
		}
		dataTypeData.getDataTypeDataDefinition().setCreationTime(creationDate);
		dataTypeData.getDataTypeDataDefinition().setModificationTime(creationDate);

		return dataTypeData;
	}

	/**
	 * add properties to capability type.
	 * 
	 * Per property, add a property node and associate it to the capability type
	 * 
	 * @param uniqueId
	 * @param properties
	 * @return
	 */
	private Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesToDataType(String uniqueId, List<PropertyDefinition> properties) {

		Map<String, PropertyData> propertiesData = new HashMap<String, PropertyData>();

		if (properties != null && false == properties.isEmpty()) {
			for (PropertyDefinition propertyDefinition : properties) {
				String propertyName = propertyDefinition.getName();

				String propertyType = propertyDefinition.getType();
				Either<Boolean, TitanOperationStatus> validPropertyType = isValidPropertyType(propertyType);
				if (validPropertyType.isRight()) {
					log.debug("Data type {} contains invalid property type {}", uniqueId, propertyType);
					return Either.right(validPropertyType.right().value());
				}
				Boolean isValid = validPropertyType.left().value();
				if (isValid == null || isValid.booleanValue() == false) {
					log.debug("Data type {} contains invalid property type {}", uniqueId, propertyType);
					return Either.right(TitanOperationStatus.INVALID_TYPE);
				}

				Either<PropertyData, TitanOperationStatus> addPropertyToNodeType = this.addPropertyToNodeType(propertyName, propertyDefinition, NodeTypeEnum.DataType, uniqueId);
				if (addPropertyToNodeType.isRight()) {
					TitanOperationStatus operationStatus = addPropertyToNodeType.right().value();
					log.debug("Failed to associate data type {} to property {} in graph. status is {}", uniqueId, propertyName, operationStatus);
					BeEcompErrorManager.getInstance().logInternalFlowError("AddPropertyToDataType", "Failed to associate property to data type. Status is " + operationStatus, ErrorSeverity.ERROR);
					return Either.right(operationStatus);
				}
				propertiesData.put(propertyName, addPropertyToNodeType.left().value());
			}

			DataTypeData dataTypeData = new DataTypeData();
			dataTypeData.getDataTypeDataDefinition().setUniqueId(uniqueId);
			long modificationTime = System.currentTimeMillis();
			dataTypeData.getDataTypeDataDefinition().setModificationTime(modificationTime);

			Either<DataTypeData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(dataTypeData, DataTypeData.class);
			if (updateNode.isRight()) {
				TitanOperationStatus operationStatus = updateNode.right().value();
				log.debug("Failed to update modification time data type {} from graph. status is {}", uniqueId, operationStatus);
				BeEcompErrorManager.getInstance().logInternalFlowError("AddPropertyToDataType", "Failed to fetch data type. Status is " + operationStatus, ErrorSeverity.ERROR);
				return Either.right(operationStatus);
			} else {
				log.debug("Update data type uid {}. Set modification time to {}", uniqueId, modificationTime);
			}

		}

		return Either.left(propertiesData);

	}

	/**
	 * Build Data type object from graph by unique id
	 * 
	 * @param uniqueId
	 * @return
	 */
	public Either<DataTypeDefinition, TitanOperationStatus> getDataTypeByUid(String uniqueId) {

		Either<DataTypeDefinition, TitanOperationStatus> result = null;

		Either<DataTypeData, TitanOperationStatus> dataTypesRes = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, DataTypeData.class);

		if (dataTypesRes.isRight()) {
			TitanOperationStatus status = dataTypesRes.right().value();
			log.debug("Data type {} cannot be found in graph. status is {}", uniqueId, status);
			return Either.right(status);
		}

		DataTypeData ctData = dataTypesRes.left().value();
		DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(ctData.getDataTypeDataDefinition());

		TitanOperationStatus propertiesStatus = fillProperties(uniqueId, dataTypeDefinition);
		if (propertiesStatus != TitanOperationStatus.OK) {
			log.error("Failed to fetch properties of data type {}", uniqueId);
			return Either.right(propertiesStatus);
		}

		Either<ImmutablePair<DataTypeData, GraphEdge>, TitanOperationStatus> parentNode = titanGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.DataType,
				DataTypeData.class);
		log.debug("After retrieving DERIVED_FROM node of {}. status is {}", uniqueId, parentNode);
		if (parentNode.isRight()) {
			TitanOperationStatus titanOperationStatus = parentNode.right().value();
			if (titanOperationStatus != TitanOperationStatus.NOT_FOUND) {
				log.error("Failed to find the parent data type of data type {}. status is {}", uniqueId, titanOperationStatus);
				result = Either.right(titanOperationStatus);
				return result;
			}
		} else {
			// derived from node was found
			ImmutablePair<DataTypeData, GraphEdge> immutablePair = parentNode.left().value();
			DataTypeData parentCT = immutablePair.getKey();

			String parentUniqueId = parentCT.getUniqueId();
			Either<DataTypeDefinition, TitanOperationStatus> dataTypeByUid = getDataTypeByUid(parentUniqueId);

			if (dataTypeByUid.isRight()) {
				return Either.right(dataTypeByUid.right().value());
			}

			DataTypeDefinition parentDataTypeDefinition = dataTypeByUid.left().value();

			dataTypeDefinition.setDerivedFrom(parentDataTypeDefinition);

		}
		result = Either.left(dataTypeDefinition);

		return result;
	}

	private TitanOperationStatus fillProperties(String uniqueId, DataTypeDefinition dataTypeDefinition) {

		Either<Map<String, PropertyDefinition>, TitanOperationStatus> findPropertiesOfNode = this.findPropertiesOfNode(NodeTypeEnum.DataType, uniqueId);
		if (findPropertiesOfNode.isRight()) {
			TitanOperationStatus titanOperationStatus = findPropertiesOfNode.right().value();
			log.debug("After looking for properties of vertex {}. status is {}", uniqueId, titanOperationStatus);
			if (TitanOperationStatus.NOT_FOUND.equals(titanOperationStatus)) {
				return TitanOperationStatus.OK;
			} else {
				return titanOperationStatus;
			}
		} else {
			Map<String, PropertyDefinition> properties = findPropertiesOfNode.left().value();
			if (properties != null && properties.isEmpty() == false) {
				List<PropertyDefinition> listOfProps = new ArrayList<>();

				for (Entry<String, PropertyDefinition> entry : properties.entrySet()) {
					String propName = entry.getKey();
					PropertyDefinition propertyDefinition = entry.getValue();
					PropertyDefinition newPropertyDefinition = new PropertyDefinition(propertyDefinition);
					newPropertyDefinition.setName(propName);
					listOfProps.add(newPropertyDefinition);
				}
				dataTypeDefinition.setProperties(listOfProps);
			}
			return TitanOperationStatus.OK;
		}
	}

	private Either<DataTypeDefinition, StorageOperationStatus> addDataType(DataTypeDefinition dataTypeDefinition, boolean inTransaction) {

		Either<DataTypeDefinition, StorageOperationStatus> result = null;

		try {

			Either<DataTypeData, TitanOperationStatus> eitherStatus = addDataTypeToGraph(dataTypeDefinition);

			if (eitherStatus.isRight()) {
				log.debug("Failed to add data type {} to Graph. status is {}", dataTypeDefinition, eitherStatus.right().value().name());
				BeEcompErrorManager.getInstance().logBeFailedAddingNodeTypeError("AddDataType", "DataType");
				result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(eitherStatus.right().value()));
				return result;
			} else {
				DataTypeData capabilityTypeData = eitherStatus.left().value();

				DataTypeDefinition dataTypeDefResult = convertDTDataToDTDefinition(capabilityTypeData);
				log.debug("The returned CapabilityTypeDefinition is {}", dataTypeDefResult);
				result = Either.left(dataTypeDefResult);
				return result;
			}
		} finally {
			if (false == inTransaction) {
				if (result == null || result.isRight()) {
					log.error("Going to execute rollback on graph.");
					titanGenericDao.rollback();
				} else {
					log.debug("Going to execute commit on graph.");
					titanGenericDao.commit();
				}
			}
		}

	}

	@Override
	public Either<DataTypeDefinition, StorageOperationStatus> addDataType(DataTypeDefinition dataTypeDefinition) {
		return addDataType(dataTypeDefinition, true);
	}

	@Override
	public Either<DataTypeDefinition, StorageOperationStatus> getDataTypeByName(String name, boolean inTransaction) {

		Either<DataTypeDefinition, StorageOperationStatus> result = null;
		try {

			String dtUid = UniqueIdBuilder.buildDataTypeUid(name);
			Either<DataTypeDefinition, TitanOperationStatus> ctResult = this.getDataTypeByUid(dtUid);

			if (ctResult.isRight()) {
				TitanOperationStatus status = ctResult.right().value();
				if (status != TitanOperationStatus.NOT_FOUND) {
					log.error("Failed to retrieve information on capability type {} status is {}", name, status);
				}
				result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(ctResult.right().value()));
				return result;
			}

			result = Either.left(ctResult.left().value());

			return result;
		} finally {
			if (false == inTransaction) {
				if (result == null || result.isRight()) {
					log.error("Going to execute rollback on graph.");
					titanGenericDao.rollback();
				} else {
					log.debug("Going to execute commit on graph.");
					titanGenericDao.commit();
				}
			}
		}

	}

	@Override
	public Either<DataTypeDefinition, StorageOperationStatus> getDataTypeByName(String name) {
		return getDataTypeByName(name, true);
	}

	@Override
	public Either<DataTypeDefinition, StorageOperationStatus> getDataTypeByNameWithoutDerived(String name) {
		return getDataTypeByNameWithoutDerived(name, true);
	}

	private Either<DataTypeDefinition, StorageOperationStatus> getDataTypeByNameWithoutDerived(String name, boolean inTransaction) {

		Either<DataTypeDefinition, StorageOperationStatus> result = null;
		try {

			String uid = UniqueIdBuilder.buildDataTypeUid(name);
			Either<DataTypeDefinition, TitanOperationStatus> ctResult = this.getDataTypeByUidWithoutDerivedDataTypes(uid);

			if (ctResult.isRight()) {
				TitanOperationStatus status = ctResult.right().value();
				if (status != TitanOperationStatus.NOT_FOUND) {
					log.error("Failed to retrieve information on capability type {} status is {}", name, status);
				}
				result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(ctResult.right().value()));
				return result;
			}

			result = Either.left(ctResult.left().value());

			return result;
		} finally {
			if (false == inTransaction) {
				if (result == null || result.isRight()) {
					log.error("Going to execute rollback on graph.");
					titanGenericDao.rollback();
				} else {
					log.debug("Going to execute commit on graph.");
					titanGenericDao.commit();
				}
			}
		}

	}

	public Either<DataTypeDefinition, TitanOperationStatus> getDataTypeByUidWithoutDerivedDataTypes(String uniqueId) {

		Either<DataTypeData, TitanOperationStatus> dataTypesRes = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, DataTypeData.class);

		if (dataTypesRes.isRight()) {
			TitanOperationStatus status = dataTypesRes.right().value();
			log.debug("Data type {} cannot be found in graph. status is {}", uniqueId, status);
			return Either.right(status);
		}

		DataTypeData ctData = dataTypesRes.left().value();
		DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(ctData.getDataTypeDataDefinition());

		TitanOperationStatus propertiesStatus = fillProperties(uniqueId, dataTypeDefinition);
		if (propertiesStatus != TitanOperationStatus.OK) {
			log.error("Failed to fetch properties of data type {}", uniqueId);
			return Either.right(propertiesStatus);
		}

		return Either.left(dataTypeDefinition);
	}

	/**
	 * 
	 * convert between graph Node object to Java object
	 * 
	 * @param dataTypeData
	 * @return
	 */
	protected DataTypeDefinition convertDTDataToDTDefinition(DataTypeData dataTypeData) {
		log.debug("The object returned after create data type is {}", dataTypeData);

		DataTypeDefinition dataTypeDefResult = new DataTypeDefinition(dataTypeData.getDataTypeDataDefinition());

		return dataTypeDefResult;
	}

	private Either<Boolean, TitanOperationStatus> isValidPropertyType(String propertyType) {

		if (propertyType == null || propertyType.isEmpty()) {
			return Either.left(false);
		}

		ToscaPropertyType toscaPropertyType = ToscaPropertyType.isValidType(propertyType);
		if (toscaPropertyType == null) {
			Either<Boolean, TitanOperationStatus> definedInDataTypes = isDefinedInDataTypes(propertyType);
			return definedInDataTypes;
		} else {
			return Either.left(true);
		}
	}

	public Either<Boolean, TitanOperationStatus> isDefinedInDataTypes(String propertyType) {

		String dataTypeUid = UniqueIdBuilder.buildDataTypeUid(propertyType);
		Either<DataTypeDefinition, TitanOperationStatus> dataTypeByUid = getDataTypeByUid(dataTypeUid);
		if (dataTypeByUid.isRight()) {
			TitanOperationStatus status = dataTypeByUid.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				return Either.left(false);
			}
			return Either.right(status);
		}

		return Either.left(true);

	}

	public Either<Map<String, DataTypeDefinition>, TitanOperationStatus> getAllDataTypes() {

		Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
		Either<Map<String, DataTypeDefinition>, TitanOperationStatus> result = Either.left(dataTypes);

		Either<List<DataTypeData>, TitanOperationStatus> getAllDataTypes = titanGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class);
		if (getAllDataTypes.isRight()) {
			TitanOperationStatus status = getAllDataTypes.right().value();
			if (status != TitanOperationStatus.NOT_FOUND) {
				return Either.right(status);
			} else {
				return result;
			}
		}

		List<DataTypeData> list = getAllDataTypes.left().value();
		if (list != null) {

			log.trace("Number of data types to load is {}" , list.size());

			List<String> collect = list.stream().map(p -> p.getDataTypeDataDefinition().getName()).collect(Collectors.toList());
			log.trace("The data types to load are {}" , collect);

			for (DataTypeData dataTypeData : list) {

				log.trace("Going to fetch data type {}. uid is {}", dataTypeData.getDataTypeDataDefinition().getName(), dataTypeData.getUniqueId());
				Either<DataTypeDefinition, TitanOperationStatus> dataTypeByUid = this.getAndAddDataTypeByUid(dataTypeData.getUniqueId(), dataTypes);
				if (dataTypeByUid.isRight()) {
					TitanOperationStatus status = dataTypeByUid.right().value();
					if (status == TitanOperationStatus.NOT_FOUND) {
						status = TitanOperationStatus.INVALID_ID;
					}
					return Either.right(status);
				}
			}
		}

		if (log.isTraceEnabled()) {
			if (result.isRight()) {
				log.trace("After fetching all data types {}" , result);
			} else {
				Map<String, DataTypeDefinition> map = result.left().value();
				if (map != null) {
					String types = map.keySet().stream().collect(Collectors.joining(",", "[", "]"));
					log.trace("After fetching all data types {} " , types);
				}
			}
		}

		return result;
	}

	/**
	 * Build Data type object from graph by unique id
	 * 
	 * @param uniqueId
	 * @return
	 */
	private Either<DataTypeDefinition, TitanOperationStatus> getAndAddDataTypeByUid(String uniqueId, Map<String, DataTypeDefinition> allDataTypes) {

		Either<DataTypeDefinition, TitanOperationStatus> result = null;

		if (allDataTypes.containsKey(uniqueId)) {
			return Either.left(allDataTypes.get(uniqueId));
		}

		Either<DataTypeData, TitanOperationStatus> dataTypesRes = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, DataTypeData.class);

		if (dataTypesRes.isRight()) {
			TitanOperationStatus status = dataTypesRes.right().value();
			log.debug("Data type {} cannot be found in graph. status is {}", uniqueId, status);
			return Either.right(status);
		}

		DataTypeData ctData = dataTypesRes.left().value();
		DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(ctData.getDataTypeDataDefinition());

		TitanOperationStatus propertiesStatus = fillProperties(uniqueId, dataTypeDefinition);
		if (propertiesStatus != TitanOperationStatus.OK) {
			log.error("Failed to fetch properties of data type {}", uniqueId);
			return Either.right(propertiesStatus);
		}

		allDataTypes.put(dataTypeDefinition.getName(), dataTypeDefinition);

		String derivedFrom = dataTypeDefinition.getDerivedFromName();
		if (allDataTypes.containsKey(derivedFrom)) {
			DataTypeDefinition parentDataTypeDefinition = allDataTypes.get(derivedFrom);

			dataTypeDefinition.setDerivedFrom(parentDataTypeDefinition);

			return Either.left(dataTypeDefinition);
		}

		Either<ImmutablePair<DataTypeData, GraphEdge>, TitanOperationStatus> parentNode = titanGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.DataType,
				DataTypeData.class);
		log.debug("After retrieving DERIVED_FROM node of {}. status is {}", uniqueId, parentNode);
		if (parentNode.isRight()) {
			TitanOperationStatus titanOperationStatus = parentNode.right().value();
			if (titanOperationStatus != TitanOperationStatus.NOT_FOUND) {
				log.error("Failed to find the parent data type of data type {}. status is {}", uniqueId, titanOperationStatus);
				result = Either.right(titanOperationStatus);
				return result;
			}
		} else {
			// derived from node was found
			ImmutablePair<DataTypeData, GraphEdge> immutablePair = parentNode.left().value();
			DataTypeData parentCT = immutablePair.getKey();

			String parentUniqueId = parentCT.getUniqueId();
			Either<DataTypeDefinition, TitanOperationStatus> dataTypeByUid = getDataTypeByUid(parentUniqueId);

			if (dataTypeByUid.isRight()) {
				return Either.right(dataTypeByUid.right().value());
			}

			DataTypeDefinition parentDataTypeDefinition = dataTypeByUid.left().value();

			dataTypeDefinition.setDerivedFrom(parentDataTypeDefinition);

		}
		result = Either.left(dataTypeDefinition);

		return result;
	}

	private Either<DataTypeDefinition, TitanOperationStatus> getDataTypeUsingName(String name) {
		String uid = UniqueIdBuilder.buildDataTypeUid(name);
		return getDataTypeByUid(uid);
	}

	public Either<String, TitanOperationStatus> checkInnerType(PropertyDataDefinition propDataDef) {

		String propertyType = propDataDef.getType();

		ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);

		return getInnerType(type, () -> propDataDef.getSchema());
	}

	public Either<List<DataTypeData>, TitanOperationStatus> getAllDataTypeNodes() {
		Either<List<DataTypeData>, TitanOperationStatus> getAllDataTypes = titanGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class);
		if (getAllDataTypes.isRight()) {
			TitanOperationStatus status = getAllDataTypes.right().value();
			if (status == TitanOperationStatus.NOT_FOUND) {
				status = TitanOperationStatus.OK;
				return Either.right(status);
			}
		}
		return getAllDataTypes;
	}

	public Either<Object, Boolean> validateAndUpdatePropertyValue(String propertyType, String value, boolean isValidate, String innerType, Map<String, DataTypeDefinition> dataTypes) {
		log.trace("Going to validate property value and its type. type = {}, value = {}", propertyType, value);
		ToscaPropertyType type = getType(propertyType);

		if (isValidate) {

			if (type == null) {
				DataTypeDefinition dataTypeDefinition = dataTypes.get(propertyType);
				ImmutablePair<JsonElement, Boolean> validateResult = dataTypeValidatorConverter.validateAndUpdate(value, dataTypeDefinition, dataTypes);
				if (Boolean.FALSE.equals(validateResult.right)) {
					log.debug("The value {} of property from type {} is invalid", value, propertyType);
					return Either.right(false);
				}
				JsonElement jsonElement = validateResult.left;
				String valueFromJsonElement = getValueFromJsonElement(jsonElement);
				return Either.left(valueFromJsonElement);
			}
			log.trace("before validating property type {}", propertyType);
			boolean isValidProperty = isValidValue(type, value, innerType, dataTypes);
			if (!isValidProperty) {
				log.debug("The value {} of property from type {} is invalid", value, type);
				return Either.right(false);
			}
		}
		Object convertedValue = value;
		if (!isEmptyValue(value) && isValidate) {
			PropertyValueConverter converter = type.getConverter();
			convertedValue = converter.convert(value, innerType, dataTypes);
		}
		return Either.left(convertedValue);
	}

	public Either<Object, Boolean> validateAndUpdatePropertyValue(String propertyType, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) {
		return validateAndUpdatePropertyValue(propertyType, value, true, innerType, dataTypes);
	}

	public <T extends GraphNode> Either<List<PropertyDefinition>, StorageOperationStatus> getAllPropertiesRec(String uniqueId, NodeTypeEnum nodeType, Class<T> clazz) {
		return this.findPropertiesOfNode(nodeType, uniqueId)
				.right()
				.bind(this::handleNotFoundProperties)
				.left()
				.bind(props -> getAllDerivedFromChainProperties(uniqueId, nodeType, clazz, props.values()));
	}

	private Either<Map<String, PropertyDefinition>, StorageOperationStatus> handleNotFoundProperties(TitanOperationStatus titanOperationStatus) {
		if (titanOperationStatus == TitanOperationStatus.NOT_FOUND) {
			return Either.left(new HashMap<>());
		}
		return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(titanOperationStatus));
	}

	private <T extends GraphNode> Either<List<PropertyDefinition>, StorageOperationStatus> getAllDerivedFromChainProperties(String uniqueId, NodeTypeEnum nodeType, Class<T> clazz, Collection<PropertyDefinition> nodeProps) {
		List<PropertyDefinition> accumulatedProps = new ArrayList<>(nodeProps);
		String currentNodeUid = uniqueId;
		Either<T, StorageOperationStatus> derivedFrom;
		while ((derivedFrom = derivedFromOperation.getDerivedFromChild(currentNodeUid, nodeType, clazz)).isLeft()) {
			currentNodeUid = derivedFrom.left().value().getUniqueId();
			TitanOperationStatus titanOperationStatus = fillProperties(currentNodeUid, nodeType, accumulatedProps::addAll);
			if (titanOperationStatus != TitanOperationStatus.OK) {
				log.debug("failed to fetch properties for type {} with id {}", nodeType, currentNodeUid);
				return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(titanOperationStatus));
			}
		}
		StorageOperationStatus getDerivedResult = derivedFrom.right().value();
		return isReachedEndOfDerivedFromChain(getDerivedResult) ? Either.left(accumulatedProps) : Either.right(getDerivedResult);
	}

	private boolean isReachedEndOfDerivedFromChain(StorageOperationStatus getDerivedResult) {
		return getDerivedResult == StorageOperationStatus.NOT_FOUND;
	}

	/*
	 * @Override public PropertyOperation getPropertyOperation() { return this; }
	 */
	protected TitanOperationStatus fillProperties(String uniqueId, NodeTypeEnum nodeType, Consumer<List<PropertyDefinition>> propertySetter) {
		Either<Map<String, PropertyDefinition>, TitanOperationStatus> findPropertiesOfNode = this.findPropertiesOfNode(nodeType, uniqueId);
		if (findPropertiesOfNode.isRight()) {
			TitanOperationStatus titanOperationStatus = findPropertiesOfNode.right().value();
			log.debug("After looking for properties of vertex {}. status is {}", uniqueId, titanOperationStatus);
			if (TitanOperationStatus.NOT_FOUND.equals(titanOperationStatus)) {
				return TitanOperationStatus.OK;
			} else {
				return titanOperationStatus;
			}
		} else {
			Map<String, PropertyDefinition> properties = findPropertiesOfNode.left().value();

			if (properties != null) {
				List<PropertyDefinition> propertiesAsList = properties.entrySet().stream().map(p -> p.getValue()).collect(Collectors.toList());
				propertySetter.accept(propertiesAsList);
			}

			return TitanOperationStatus.OK;
		}
	}

	/**
	 * add properties to element type.
	 * 
	 * Per property, add a property node and associate it to the element type
	 * 
	 * @param uniqueId
	 * @param propertiesMap
	 *            
	 * @return
	 */
	protected Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesToElementType(String uniqueId, NodeTypeEnum nodeType, Map<String, PropertyDefinition> propertiesMap) {

		Map<String, PropertyData> propertiesData = new HashMap<String, PropertyData>();

		if (propertiesMap != null) {

			for (Entry<String, PropertyDefinition> propertyDefinitionEntry : propertiesMap.entrySet()) {
				String propertyName = propertyDefinitionEntry.getKey();

				Either<PropertyData, TitanOperationStatus> addPropertyToNodeType = this.addPropertyToNodeType(propertyName, propertyDefinitionEntry.getValue(), nodeType, uniqueId);

				if (addPropertyToNodeType.isRight()) {
					TitanOperationStatus operationStatus = addPropertyToNodeType.right().value();
					log.error("Failed to associate {} {} to property {} in graph. status is {}", nodeType.getName(), uniqueId, propertyName, operationStatus);
					return Either.right(operationStatus);
				}
				propertiesData.put(propertyName, addPropertyToNodeType.left().value());

			}
		}

		return Either.left(propertiesData);

	}

	public Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesToElementType(String uniqueId, NodeTypeEnum elementType, List<PropertyDefinition> properties) {

		Map<String, PropertyDefinition> propMap;
		if (properties == null) {
			propMap = null;
		} else {
			propMap = properties.stream().collect(Collectors.toMap(propDef -> propDef.getName(), propDef -> propDef));
		}
		return addPropertiesToElementType(uniqueId, elementType, propMap);
	}

	@Override
	public Either<DataTypeDefinition, StorageOperationStatus> updateDataType(DataTypeDefinition newDataTypeDefinition, DataTypeDefinition oldDataTypeDefinition) {
		return updateDataType(newDataTypeDefinition, oldDataTypeDefinition, true);
	}

	private Either<DataTypeDefinition, StorageOperationStatus> updateDataType(DataTypeDefinition newDataTypeDefinition, DataTypeDefinition oldDataTypeDefinition, boolean inTransaction) {

		Either<DataTypeDefinition, StorageOperationStatus> result = null;

		try {

			List<PropertyDefinition> newProperties = newDataTypeDefinition.getProperties();

			List<PropertyDefinition> oldProperties = oldDataTypeDefinition.getProperties();

			String newDerivedFromName = getDerivedFromName(newDataTypeDefinition);

			String oldDerivedFromName = getDerivedFromName(oldDataTypeDefinition);

			String dataTypeName = newDataTypeDefinition.getName();

			List<PropertyDefinition> propertiesToAdd = new ArrayList<>();
			if (isPropertyOmitted(newProperties, oldProperties, dataTypeName) || isPropertyTypeChanged(dataTypeName, newProperties, oldProperties, propertiesToAdd) || isDerivedFromNameChanged(dataTypeName, newDerivedFromName, oldDerivedFromName)) {

				log.debug("The new data type {} is invalid.", dataTypeName);

				result = Either.right(StorageOperationStatus.CANNOT_UPDATE_EXISTING_ENTITY);
				return result;
			}

			if (propertiesToAdd == null || propertiesToAdd.isEmpty()) {
				log.debug("No new properties has been defined in the new data type {}", newDataTypeDefinition);
				result = Either.right(StorageOperationStatus.OK);
				return result;
			}

			Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesToDataType = addPropertiesToDataType(oldDataTypeDefinition.getUniqueId(), propertiesToAdd);

			if (addPropertiesToDataType.isRight()) {
				log.debug("Failed to update data type {} to Graph. Status is {}", oldDataTypeDefinition, addPropertiesToDataType.right().value().name());
				BeEcompErrorManager.getInstance().logBeFailedAddingNodeTypeError("UpdateDataType", "Property");
				result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(addPropertiesToDataType.right().value()));
				return result;
			} else {

				Either<DataTypeDefinition, TitanOperationStatus> dataTypeByUid = this.getDataTypeByUid(oldDataTypeDefinition.getUniqueId());
				if (dataTypeByUid.isRight()) {
					TitanOperationStatus status = addPropertiesToDataType.right().value();
					log.debug("Failed to get data type {} after update. Status is {}", oldDataTypeDefinition.getUniqueId(), status.name());
					BeEcompErrorManager.getInstance().logBeFailedRetrieveNodeError("UpdateDataType", "Property", status.name());
					result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
				} else {
					result = Either.left(dataTypeByUid.left().value());
				}
			}

			return result;

		} finally {
			if (false == inTransaction) {
				if (result == null || result.isRight()) {
					log.error("Going to execute rollback on graph.");
					titanGenericDao.rollback();
				} else {
					log.debug("Going to execute commit on graph.");
					titanGenericDao.commit();
				}
			}
		}

	}

	private String getDerivedFromName(DataTypeDefinition dataTypeDefinition) {
		String derivedFromName = dataTypeDefinition.getDerivedFromName();
		return derivedFromName;
	}

	private boolean isPropertyTypeChanged(String dataTypeName, List<PropertyDefinition> newProperties, List<PropertyDefinition> oldProperties, List<PropertyDefinition> outputPropertiesToAdd) {

		if (newProperties != null && oldProperties != null) {

			Map<String, PropertyDefinition> newPropsMapper = newProperties.stream().collect(Collectors.toMap(p -> p.getName(), p -> p));
			Map<String, PropertyDefinition> oldPropsMapper = oldProperties.stream().collect(Collectors.toMap(p -> p.getName(), p -> p));

			for (Entry<String, PropertyDefinition> newPropertyEntry : newPropsMapper.entrySet()) {

				String propName = newPropertyEntry.getKey();
				PropertyDefinition propDef = newPropertyEntry.getValue();

				PropertyDefinition oldPropertyDefinition = oldPropsMapper.get(propName);
				if (oldPropertyDefinition == null) {
					log.debug("New property {} received in the data type {}", propName, dataTypeName);
					outputPropertiesToAdd.add(propDef);
					continue;
				}

				String oldType = oldPropertyDefinition.getType();
				String oldEntryType = getEntryType(oldPropertyDefinition);

				String newType = propDef.getType();
				String newEntryType = getEntryType(propDef);

				if (false == oldType.equals(newType)) {
					log.debug("Existing property {} in data type {} has a differnet type {} than the new one {}", propName, dataTypeName, oldType, newType);
					return true;
				}

				if (false == equalsEntryTypes(oldEntryType, newEntryType)) {
					log.debug("Existing property {} in data type {} has a differnet entry type {} than the new one {}", propName, dataTypeName, oldEntryType, newEntryType);
					return true;
				}

			}

		}

		return false;
	}

	private boolean equalsEntryTypes(String oldEntryType, String newEntryType) {

		if (oldEntryType == null && newEntryType == null) {
			return true;
		} else if (oldEntryType != null && newEntryType != null) {
			return oldEntryType.equals(newEntryType);
		} else {
			return false;
		}
	}

	private String getEntryType(PropertyDefinition oldPropertyDefinition) {
		String entryType = null;
		SchemaDefinition schema = oldPropertyDefinition.getSchema();
		if (schema != null) {
			PropertyDataDefinition schemaProperty = schema.getProperty();
			if (schemaProperty != null) {
				entryType = schemaProperty.getType();
			}
		}
		return entryType;
	}

	private boolean isPropertyOmitted(List<PropertyDefinition> newProperties, List<PropertyDefinition> oldProperties, String dataTypeName) {

		boolean isValid = validateChangeInCaseOfEmptyProperties(newProperties, oldProperties, dataTypeName);
		if (false == isValid) {
			log.debug("At least one property is missing in the new data type {}", dataTypeName);
			return false;
		}

		if (newProperties != null && oldProperties != null) {

			List<String> newProps = newProperties.stream().map(p -> p.getName()).collect(Collectors.toList());
			List<String> oldProps = oldProperties.stream().map(p -> p.getName()).collect(Collectors.toList());

			if (false == newProps.containsAll(oldProps)) {
				StringJoiner joiner = new StringJoiner(",", "[", "]");
				newProps.forEach(p -> joiner.add(p));
				log.debug("Properties {} in data type {} are missing, but they already defined in the existing data type", joiner.toString(), dataTypeName);
				return true;
			}

		}
		return false;
	}

	private boolean validateChangeInCaseOfEmptyProperties(List<PropertyDefinition> newProperties, List<PropertyDefinition> oldProperties, String dataTypeName) {

		if (newProperties != null) {
			if (newProperties.isEmpty()) {
				newProperties = null;
			}
		}

		if (oldProperties != null) {
			if (oldProperties.isEmpty()) {
				oldProperties = null;
			}
		}

		if ((newProperties == null && oldProperties == null) || (newProperties != null && oldProperties != null)) {
			return true;
		}

		return false;
	}

	private boolean isDerivedFromNameChanged(String dataTypeName, String newDerivedFromName, String oldDerivedFromName) {

		if (newDerivedFromName != null) {
			boolean isEqual = newDerivedFromName.equals(oldDerivedFromName);
			if (false == isEqual) {
				log.debug("The new datatype {} derived from another data type {} than the existing one {}", dataTypeName, newDerivedFromName, oldDerivedFromName);
			}
			return !isEqual;
		} else if (oldDerivedFromName == null) {
			return false;
		} else {// new=null, old != null
			log.debug("The new datatype {} derived from another data type {} than the existing one {}", dataTypeName, newDerivedFromName, oldDerivedFromName);
			return true;
		}

	}

	/**
	 * 
	 * Future - unfinished
	 * 
	 * @param type
	 * @param value
	 * @return
	 */
	public boolean isValueToscaFunction(String type, String value) {

		boolean result = false;

		if (ToscaPropertyType.STRING.getType().equals(type) || isScalarDerivedFromString(type)) {

		}

		String[] functions = { "get_input" };

		if (value != null) {

			for (String function : functions) {

			}

		}

		return result;

	}

	/**
	 * Future - unfinished
	 * 
	 * @param type
	 * @return
	 */
	private boolean isScalarDerivedFromString(String type) {
		// TODO Auto-generated method stub
		return false;
	}
}